Category: Matlab
Category Archives: Matlab
Backlash block does not simulate gears backlash
Different behavior is shown by the multibody backlash block, which is designed to more accurately model the backlash of gears. See picture below. Note: it is speeds, not angles. What I am referring to is initial constantness of speed when it changes direction. Also ignore staircase-like behavior: obviously, it is more accurate model then simulink’s one so it takes more physical processes into account.
You can compare it to the output of simulink backlash block (for convenience, see below from official example, note: this is angles). Here one can see initial angle constantness.
I think, simulink’s block does not simulate gears backlash correctly (and multibody block does). Gears disengage when torque changes sign => when speed changes direction (because at this moment motor will start pushing in the opposite direction then before, but there is no contact to the opposite gear => backlash occures. Exactly at this moment torque = 0 (changes its sign) and speed tries to change direction: before this moment gear was accelerating and after it starts to slow down). So this constantness should occure on the speed level. But disangagment should be calculated on the angles level. Therefore it can’t be simulated by simulink’s block (and indeed simulink’s multibody block shows different behaviour).
P.S. Sorry for my english, it is not my native language.Different behavior is shown by the multibody backlash block, which is designed to more accurately model the backlash of gears. See picture below. Note: it is speeds, not angles. What I am referring to is initial constantness of speed when it changes direction. Also ignore staircase-like behavior: obviously, it is more accurate model then simulink’s one so it takes more physical processes into account.
You can compare it to the output of simulink backlash block (for convenience, see below from official example, note: this is angles). Here one can see initial angle constantness.
I think, simulink’s block does not simulate gears backlash correctly (and multibody block does). Gears disengage when torque changes sign => when speed changes direction (because at this moment motor will start pushing in the opposite direction then before, but there is no contact to the opposite gear => backlash occures. Exactly at this moment torque = 0 (changes its sign) and speed tries to change direction: before this moment gear was accelerating and after it starts to slow down). So this constantness should occure on the speed level. But disangagment should be calculated on the angles level. Therefore it can’t be simulated by simulink’s block (and indeed simulink’s multibody block shows different behaviour).
P.S. Sorry for my english, it is not my native language. Different behavior is shown by the multibody backlash block, which is designed to more accurately model the backlash of gears. See picture below. Note: it is speeds, not angles. What I am referring to is initial constantness of speed when it changes direction. Also ignore staircase-like behavior: obviously, it is more accurate model then simulink’s one so it takes more physical processes into account.
You can compare it to the output of simulink backlash block (for convenience, see below from official example, note: this is angles). Here one can see initial angle constantness.
I think, simulink’s block does not simulate gears backlash correctly (and multibody block does). Gears disengage when torque changes sign => when speed changes direction (because at this moment motor will start pushing in the opposite direction then before, but there is no contact to the opposite gear => backlash occures. Exactly at this moment torque = 0 (changes its sign) and speed tries to change direction: before this moment gear was accelerating and after it starts to slow down). So this constantness should occure on the speed level. But disangagment should be calculated on the angles level. Therefore it can’t be simulated by simulink’s block (and indeed simulink’s multibody block shows different behaviour).
P.S. Sorry for my english, it is not my native language. backlash, deadband, dead zone MATLAB Answers — New Questions
Is it possible to recover a corrupted *.mlapp file?
I was working on an app and had just got the thing to work when the file became corrupted. When I tried to run the file (and now when I try to open it), I get an error dialog:
"Error loading ‘PlotDigitizer.mlapp’.
And then this appears in the command window:
"Error using which
C:WorkMatlabAppsPlot DigitizerPlotDigitizer.mlapp: Can’t open file.
Error in run (line 55)
pathscript = evalin(‘caller’, strcat(‘which(”’, script, ”’)’));"
I tried to find a solution to this online and came up with reseting preferences… which didn’t work.
This the second time this has occured, forcing me to loose several hours of work, and I am not even sure what I did to cause it, if anything. It seemingly worked one minute and then not the next.
Is App Designer that unstable? Is there a way to recover this or at least copy the text portion of the code?
Also, what options do I have for backup or autosave?I was working on an app and had just got the thing to work when the file became corrupted. When I tried to run the file (and now when I try to open it), I get an error dialog:
"Error loading ‘PlotDigitizer.mlapp’.
And then this appears in the command window:
"Error using which
C:WorkMatlabAppsPlot DigitizerPlotDigitizer.mlapp: Can’t open file.
Error in run (line 55)
pathscript = evalin(‘caller’, strcat(‘which(”’, script, ”’)’));"
I tried to find a solution to this online and came up with reseting preferences… which didn’t work.
This the second time this has occured, forcing me to loose several hours of work, and I am not even sure what I did to cause it, if anything. It seemingly worked one minute and then not the next.
Is App Designer that unstable? Is there a way to recover this or at least copy the text portion of the code?
Also, what options do I have for backup or autosave? I was working on an app and had just got the thing to work when the file became corrupted. When I tried to run the file (and now when I try to open it), I get an error dialog:
"Error loading ‘PlotDigitizer.mlapp’.
And then this appears in the command window:
"Error using which
C:WorkMatlabAppsPlot DigitizerPlotDigitizer.mlapp: Can’t open file.
Error in run (line 55)
pathscript = evalin(‘caller’, strcat(‘which(”’, script, ”’)’));"
I tried to find a solution to this online and came up with reseting preferences… which didn’t work.
This the second time this has occured, forcing me to loose several hours of work, and I am not even sure what I did to cause it, if anything. It seemingly worked one minute and then not the next.
Is App Designer that unstable? Is there a way to recover this or at least copy the text portion of the code?
Also, what options do I have for backup or autosave? appdesigner, corrupted file, backup MATLAB Answers — New Questions
Failed to open file ‘…mcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’ when using plot in standalone exe
My standalone application (executable file on Windows 10) works well in performing a variety of task: reading and writing files, executing third party software, make computations, plot charts, log diary, move files, etc. I also need to show the console during execution as it reports a diary of the operations performed, warnings, and some output data.
The final output data are a few lines on the console and a plot. The console is intended to reproduce the same output of the MATLAB command window. However, any time the mouse pointer is hovering on the plot generated by the standalone executable, the command line throws a long sequence of errors:
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Warning: Error occurred while executing the listener callback for event WindowMouseMotion defined for class matlab.ui.Figure:
The file
"C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m"
cannot be executed.
Error in matlab.graphics.interaction.actions.Linger/startTimer
Error in matlab.graphics.interaction.actions.Linger/motionCallback
Error in matlab.graphics.interaction.actions.Linger
> In waitforallfiguresclosed (line 20)
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Warning: Error occurred while executing the listener callback for event ButtonExited defined for class matlab.graphics.primitive.canvas.JavaCanvas:
The file
"C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m"
cannot be executed.
This happened on R2022b on different machines with Windows 10. The exe provides the same results of the MATLAB script and everything works fine, except for the errors reported above. I tried to disable the interactivity of the plot, avoid moving files, using a different type of the plot: the issue is always present.
Due to the complexity and the confidentiality of my work I will report a minimum and generic working example that provides the same issue. It is sufficient to generate the executable file of the following code with the Application Compiler:
close all; clearvars; clc
A = magic(5);
plot(A,’o-‘)
grid on
title(‘Call it magic’)
with the additional runtime setting "Do not display the Windows Command Shell…" disabled. I get something like the following screenshot.
Any advice on how to solve?My standalone application (executable file on Windows 10) works well in performing a variety of task: reading and writing files, executing third party software, make computations, plot charts, log diary, move files, etc. I also need to show the console during execution as it reports a diary of the operations performed, warnings, and some output data.
The final output data are a few lines on the console and a plot. The console is intended to reproduce the same output of the MATLAB command window. However, any time the mouse pointer is hovering on the plot generated by the standalone executable, the command line throws a long sequence of errors:
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Warning: Error occurred while executing the listener callback for event WindowMouseMotion defined for class matlab.ui.Figure:
The file
"C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m"
cannot be executed.
Error in matlab.graphics.interaction.actions.Linger/startTimer
Error in matlab.graphics.interaction.actions.Linger/motionCallback
Error in matlab.graphics.interaction.actions.Linger
> In waitforallfiguresclosed (line 20)
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Warning: Error occurred while executing the listener callback for event ButtonExited defined for class matlab.graphics.primitive.canvas.JavaCanvas:
The file
"C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m"
cannot be executed.
This happened on R2022b on different machines with Windows 10. The exe provides the same results of the MATLAB script and everything works fine, except for the errors reported above. I tried to disable the interactivity of the plot, avoid moving files, using a different type of the plot: the issue is always present.
Due to the complexity and the confidentiality of my work I will report a minimum and generic working example that provides the same issue. It is sufficient to generate the executable file of the following code with the Application Compiler:
close all; clearvars; clc
A = magic(5);
plot(A,’o-‘)
grid on
title(‘Call it magic’)
with the additional runtime setting "Do not display the Windows Command Shell…" disabled. I get something like the following screenshot.
Any advice on how to solve? My standalone application (executable file on Windows 10) works well in performing a variety of task: reading and writing files, executing third party software, make computations, plot charts, log diary, move files, etc. I also need to show the console during execution as it reports a diary of the operations performed, warnings, and some output data.
The final output data are a few lines on the console and a plot. The console is intended to reproduce the same output of the MATLAB command window. However, any time the mouse pointer is hovering on the plot generated by the standalone executable, the command line throws a long sequence of errors:
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Warning: Error occurred while executing the listener callback for event WindowMouseMotion defined for class matlab.ui.Figure:
The file
"C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m"
cannot be executed.
Error in matlab.graphics.interaction.actions.Linger/startTimer
Error in matlab.graphics.interaction.actions.Linger/motionCallback
Error in matlab.graphics.interaction.actions.Linger
> In waitforallfiguresclosed (line 20)
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Failed to open file ‘C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m’. Details: ‘File stream is closed. The following flags are set: failbit.’
Warning: Error occurred while executing the listener callback for event ButtonExited defined for class matlab.graphics.primitive.canvas.JavaCanvas:
The file
"C:Program FilesMATLABMATLAB RuntimeR2022bmcrtoolboxmatlabiofun@timertimer.m"
cannot be executed.
This happened on R2022b on different machines with Windows 10. The exe provides the same results of the MATLAB script and everything works fine, except for the errors reported above. I tried to disable the interactivity of the plot, avoid moving files, using a different type of the plot: the issue is always present.
Due to the complexity and the confidentiality of my work I will report a minimum and generic working example that provides the same issue. It is sufficient to generate the executable file of the following code with the Application Compiler:
close all; clearvars; clc
A = magic(5);
plot(A,’o-‘)
grid on
title(‘Call it magic’)
with the additional runtime setting "Do not display the Windows Command Shell…" disabled. I get something like the following screenshot.
Any advice on how to solve? standalone, matlab compiler, executable, plot MATLAB Answers — New Questions
How to measure the power of the VSC port
I want to simulate the dynamic voltage restorer simulation, but the strange thing is that when the load voltage is normal, the output reactive power should be 0, but the VSC port outputs a lot of reactive power, which should not be the case.I want to simulate the dynamic voltage restorer simulation, but the strange thing is that when the load voltage is normal, the output reactive power should be 0, but the VSC port outputs a lot of reactive power, which should not be the case. I want to simulate the dynamic voltage restorer simulation, but the strange thing is that when the load voltage is normal, the output reactive power should be 0, but the VSC port outputs a lot of reactive power, which should not be the case. dvr vsc MATLAB Answers — New Questions
Simscape Battery Onramp will not launch in browser. “License checkout failed. License Manager Error -5 . Cannot find a license for simscape_battery.”
Here is the error code and error messages I got. Further down I used the "ver -support" command to see which products is included in this browser version of MATLAB.
License checkout failed.
License Manager Error -5
Cannot find a license for simscape_battery.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/5
Diagnostic Information:
Feature: simscape_battery
License path: 13501@flexlm-24a-40912989-us-east-1a.wsroute.mathworks.com:13501@flexlm-24a-40912989-us-east-1d.wsroute.mathworks.com:13501@flexlm-24a-40912989-us-east-1e.wsroute.mathworks.com:/home/mluser/.matlab/R2024a_licenses:/MATLAB/licenses/license.dat:/MATLAB/licenses
Licensing error: -5,0.
Error using learning.simulink.launchOnramp
Unable to check out a Simscape Battery license, which is required by Simscape Battery Onramp.
Alternatively, you can take the course on the MathWorks Self-Paced Online Courses website.
>> ver -support
—————————————————————————————————–
MATLAB Version: 24.1.0.2570885 (R2024a) Update 1
MATLAB License Number:
Operating System: Linux 5.4.233-0504233-generic #202302250651 SMP Sat Feb 25 12:26:27 UTC 2023 x86_64
Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a) License
Simulink Version 24.1 (R2024a) License
Requirements Toolbox Version 24.1 (R2024a) License
Simscape Version 24.1 (R2024a) License
Simscape Electrical Version 24.1 (R2024a) License
Simulink Control Design Version 24.1 (R2024a) License
Simulink Test Version 24.1 (R2024a) License
Stateflow Version 24.1 (R2024a) License
System Composer Version 24.1 (R2024a) License
>>
The command "license(‘inuse’)" show that a license has been checked out for a feature called ‘simscapebattery’, without underscore.Here is the error code and error messages I got. Further down I used the "ver -support" command to see which products is included in this browser version of MATLAB.
License checkout failed.
License Manager Error -5
Cannot find a license for simscape_battery.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/5
Diagnostic Information:
Feature: simscape_battery
License path: 13501@flexlm-24a-40912989-us-east-1a.wsroute.mathworks.com:13501@flexlm-24a-40912989-us-east-1d.wsroute.mathworks.com:13501@flexlm-24a-40912989-us-east-1e.wsroute.mathworks.com:/home/mluser/.matlab/R2024a_licenses:/MATLAB/licenses/license.dat:/MATLAB/licenses
Licensing error: -5,0.
Error using learning.simulink.launchOnramp
Unable to check out a Simscape Battery license, which is required by Simscape Battery Onramp.
Alternatively, you can take the course on the MathWorks Self-Paced Online Courses website.
>> ver -support
—————————————————————————————————–
MATLAB Version: 24.1.0.2570885 (R2024a) Update 1
MATLAB License Number:
Operating System: Linux 5.4.233-0504233-generic #202302250651 SMP Sat Feb 25 12:26:27 UTC 2023 x86_64
Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a) License
Simulink Version 24.1 (R2024a) License
Requirements Toolbox Version 24.1 (R2024a) License
Simscape Version 24.1 (R2024a) License
Simscape Electrical Version 24.1 (R2024a) License
Simulink Control Design Version 24.1 (R2024a) License
Simulink Test Version 24.1 (R2024a) License
Stateflow Version 24.1 (R2024a) License
System Composer Version 24.1 (R2024a) License
>>
The command "license(‘inuse’)" show that a license has been checked out for a feature called ‘simscapebattery’, without underscore. Here is the error code and error messages I got. Further down I used the "ver -support" command to see which products is included in this browser version of MATLAB.
License checkout failed.
License Manager Error -5
Cannot find a license for simscape_battery.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/5
Diagnostic Information:
Feature: simscape_battery
License path: 13501@flexlm-24a-40912989-us-east-1a.wsroute.mathworks.com:13501@flexlm-24a-40912989-us-east-1d.wsroute.mathworks.com:13501@flexlm-24a-40912989-us-east-1e.wsroute.mathworks.com:/home/mluser/.matlab/R2024a_licenses:/MATLAB/licenses/license.dat:/MATLAB/licenses
Licensing error: -5,0.
Error using learning.simulink.launchOnramp
Unable to check out a Simscape Battery license, which is required by Simscape Battery Onramp.
Alternatively, you can take the course on the MathWorks Self-Paced Online Courses website.
>> ver -support
—————————————————————————————————–
MATLAB Version: 24.1.0.2570885 (R2024a) Update 1
MATLAB License Number:
Operating System: Linux 5.4.233-0504233-generic #202302250651 SMP Sat Feb 25 12:26:27 UTC 2023 x86_64
Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a) License
Simulink Version 24.1 (R2024a) License
Requirements Toolbox Version 24.1 (R2024a) License
Simscape Version 24.1 (R2024a) License
Simscape Electrical Version 24.1 (R2024a) License
Simulink Control Design Version 24.1 (R2024a) License
Simulink Test Version 24.1 (R2024a) License
Stateflow Version 24.1 (R2024a) License
System Composer Version 24.1 (R2024a) License
>>
The command "license(‘inuse’)" show that a license has been checked out for a feature called ‘simscapebattery’, without underscore. onramp course, simscape battery, launch in browser MATLAB Answers — New Questions
How to compile two different array type into one variable
rootdir = ‘C:UsersacerDesktopabc’;
filelist = dir(fullfile(rootdir,’***.xlsx’));
X = []; Y = [];
for ii = 1:length(filelist)
filelist(ii).data = importdata(fullfile(filelist(ii).folder,filelist(ii).name));
filelist(ii).data = (filelist(ii).data(:,:));
end
% combine all the data, one after the other, vertically:
all_data = vertcat(filelist.data); %this is where the error lies, since the data file were struct and cell
% How to convert all struct to cell assuming I have multiple struct file.rootdir = ‘C:UsersacerDesktopabc’;
filelist = dir(fullfile(rootdir,’***.xlsx’));
X = []; Y = [];
for ii = 1:length(filelist)
filelist(ii).data = importdata(fullfile(filelist(ii).folder,filelist(ii).name));
filelist(ii).data = (filelist(ii).data(:,:));
end
% combine all the data, one after the other, vertically:
all_data = vertcat(filelist.data); %this is where the error lies, since the data file were struct and cell
% How to convert all struct to cell assuming I have multiple struct file. rootdir = ‘C:UsersacerDesktopabc’;
filelist = dir(fullfile(rootdir,’***.xlsx’));
X = []; Y = [];
for ii = 1:length(filelist)
filelist(ii).data = importdata(fullfile(filelist(ii).folder,filelist(ii).name));
filelist(ii).data = (filelist(ii).data(:,:));
end
% combine all the data, one after the other, vertically:
all_data = vertcat(filelist.data); %this is where the error lies, since the data file were struct and cell
% How to convert all struct to cell assuming I have multiple struct file. cell, struct, importing excel data, data import, compile, convert, combine MATLAB Answers — New Questions
How to automatically select the number of Latent variables – plsda script
Hi,
I have a question. Using PLS_Toolbox to do a plsda model, when I upload the calibration datasets X and Y, the toolbox can automatically select the numebr of latent variables. Is there a way to "translate" this in a matlab scritpt?
After the cross-validation, is there anyway to make the script select automatically the number of components? Is there any function? My Y dataset is made of 3 columns and for each column we have 1 or 0 dependent on whether or not that sample belongs to that class.
% Modello PLS-DA prima della cross_val
modello_in=evrimodel(‘plsda’);
% Calibrazione Modello PLS-DA prima della cross_val
modello_in.x=Xcal;
modello_in.y=Ycal;
modello_in.ncomp=5; % 5 LVs
modello_in.options.preprocessing={‘autoscale’ ‘autoscale’};
modello_in.options.display=’off’;
modello_in=modello_in.crossvalidate({‘vet’ 10}, 15);Hi,
I have a question. Using PLS_Toolbox to do a plsda model, when I upload the calibration datasets X and Y, the toolbox can automatically select the numebr of latent variables. Is there a way to "translate" this in a matlab scritpt?
After the cross-validation, is there anyway to make the script select automatically the number of components? Is there any function? My Y dataset is made of 3 columns and for each column we have 1 or 0 dependent on whether or not that sample belongs to that class.
% Modello PLS-DA prima della cross_val
modello_in=evrimodel(‘plsda’);
% Calibrazione Modello PLS-DA prima della cross_val
modello_in.x=Xcal;
modello_in.y=Ycal;
modello_in.ncomp=5; % 5 LVs
modello_in.options.preprocessing={‘autoscale’ ‘autoscale’};
modello_in.options.display=’off’;
modello_in=modello_in.crossvalidate({‘vet’ 10}, 15); Hi,
I have a question. Using PLS_Toolbox to do a plsda model, when I upload the calibration datasets X and Y, the toolbox can automatically select the numebr of latent variables. Is there a way to "translate" this in a matlab scritpt?
After the cross-validation, is there anyway to make the script select automatically the number of components? Is there any function? My Y dataset is made of 3 columns and for each column we have 1 or 0 dependent on whether or not that sample belongs to that class.
% Modello PLS-DA prima della cross_val
modello_in=evrimodel(‘plsda’);
% Calibrazione Modello PLS-DA prima della cross_val
modello_in.x=Xcal;
modello_in.y=Ycal;
modello_in.ncomp=5; % 5 LVs
modello_in.options.preprocessing={‘autoscale’ ‘autoscale’};
modello_in.options.display=’off’;
modello_in=modello_in.crossvalidate({‘vet’ 10}, 15); pls, plsda, pls_toolbox MATLAB Answers — New Questions
Check input is a string or Char if so reprompt
I am struggling to fidn a way to check a input if its any type of string or char and if so reprompt the user.
Code is below:
a = input("Please enter a number: "); %Takes user input for number that is to be converted
while isempty(a)
disp(‘Invalid input please enter a number!’)
a = input("Please enter a number: ");
end
convtype = input("Please enter the conversion type: "); %Takes user input for the cnversion type that they want
while isempty(convtype)|| convtype < 1 || convtype > 14
disp(‘Invalid conversion type selection please make a selection between 1 and 14!’)
convtype = input("Please enter the conversion type: ");
endI am struggling to fidn a way to check a input if its any type of string or char and if so reprompt the user.
Code is below:
a = input("Please enter a number: "); %Takes user input for number that is to be converted
while isempty(a)
disp(‘Invalid input please enter a number!’)
a = input("Please enter a number: ");
end
convtype = input("Please enter the conversion type: "); %Takes user input for the cnversion type that they want
while isempty(convtype)|| convtype < 1 || convtype > 14
disp(‘Invalid conversion type selection please make a selection between 1 and 14!’)
convtype = input("Please enter the conversion type: ");
end I am struggling to fidn a way to check a input if its any type of string or char and if so reprompt the user.
Code is below:
a = input("Please enter a number: "); %Takes user input for number that is to be converted
while isempty(a)
disp(‘Invalid input please enter a number!’)
a = input("Please enter a number: ");
end
convtype = input("Please enter the conversion type: "); %Takes user input for the cnversion type that they want
while isempty(convtype)|| convtype < 1 || convtype > 14
disp(‘Invalid conversion type selection please make a selection between 1 and 14!’)
convtype = input("Please enter the conversion type: ");
end matlab MATLAB Answers — New Questions
How do I make a counter count every three clock cycle like 1 after three clock cycle 2 after three clock cycle 3 and so on in xilinx matlab system generator simulink..
I was desiging a project where i want how I can make the counter count every three clock cycle like 1 after three clock cycle 2 after three clock cycle 3 and so on in the wave scope.I was desiging a project where i want how I can make the counter count every three clock cycle like 1 after three clock cycle 2 after three clock cycle 3 and so on in the wave scope. I was desiging a project where i want how I can make the counter count every three clock cycle like 1 after three clock cycle 2 after three clock cycle 3 and so on in the wave scope. xilinx, counter, simulink MATLAB Answers — New Questions
Runge-Kutta 4th order method
% It calculates ODE using Runge-Kutta 4th order method
% Author Ido Schwartz
clc; % Clears the screen
clear;
h=5; % step size
x = 0:h:100; % Calculates upto y(3)
Y = zeros(1,length(x));
y(1) = [-0.5;0.3;0.2];
% initial condition
F_xy = @(t,r) 3.*exp(-t)-0.4*r; % change the function as you desire
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((x(i)+h),(y(i)+k_3*h));
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
display(Y(i+1));
if i run the programme i get answer =0;
how can i solve this problem if i have three initial condition -0.5 ,0.3 and 0.2
while x=0:5:100
and how i can plot the answer with respect to x?% It calculates ODE using Runge-Kutta 4th order method
% Author Ido Schwartz
clc; % Clears the screen
clear;
h=5; % step size
x = 0:h:100; % Calculates upto y(3)
Y = zeros(1,length(x));
y(1) = [-0.5;0.3;0.2];
% initial condition
F_xy = @(t,r) 3.*exp(-t)-0.4*r; % change the function as you desire
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((x(i)+h),(y(i)+k_3*h));
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
display(Y(i+1));
if i run the programme i get answer =0;
how can i solve this problem if i have three initial condition -0.5 ,0.3 and 0.2
while x=0:5:100
and how i can plot the answer with respect to x? % It calculates ODE using Runge-Kutta 4th order method
% Author Ido Schwartz
clc; % Clears the screen
clear;
h=5; % step size
x = 0:h:100; % Calculates upto y(3)
Y = zeros(1,length(x));
y(1) = [-0.5;0.3;0.2];
% initial condition
F_xy = @(t,r) 3.*exp(-t)-0.4*r; % change the function as you desire
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((x(i)+h),(y(i)+k_3*h));
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
display(Y(i+1));
if i run the programme i get answer =0;
how can i solve this problem if i have three initial condition -0.5 ,0.3 and 0.2
while x=0:5:100
and how i can plot the answer with respect to x? runge-kutta 4th order method MATLAB Answers — New Questions
Battery pack(battery builder app) to SOC estimator connection issue
The input signal to ‘Input Port 2’ of subsystem ‘BatterypackSOCSOHCHARGEDISCHARGE/SOC Estimator (Adaptive Kalman Filter)’ has a size of 4 for dimension 1. Given the partition width 1 and the partition offset 0 for this input, subsystem ‘BatterypackSOCSOHCHARGEDISCHARGE/SOC Estimator (Adaptive Kalman Filter)’ requires 4 iterations. This requirement conflicts with 1, the number of iterations expected by another input/output signal of this subsystem.
I am getting this error as i have build battery pack from battery builder and connecting the block shows this error. check imageThe input signal to ‘Input Port 2’ of subsystem ‘BatterypackSOCSOHCHARGEDISCHARGE/SOC Estimator (Adaptive Kalman Filter)’ has a size of 4 for dimension 1. Given the partition width 1 and the partition offset 0 for this input, subsystem ‘BatterypackSOCSOHCHARGEDISCHARGE/SOC Estimator (Adaptive Kalman Filter)’ requires 4 iterations. This requirement conflicts with 1, the number of iterations expected by another input/output signal of this subsystem.
I am getting this error as i have build battery pack from battery builder and connecting the block shows this error. check image The input signal to ‘Input Port 2’ of subsystem ‘BatterypackSOCSOHCHARGEDISCHARGE/SOC Estimator (Adaptive Kalman Filter)’ has a size of 4 for dimension 1. Given the partition width 1 and the partition offset 0 for this input, subsystem ‘BatterypackSOCSOHCHARGEDISCHARGE/SOC Estimator (Adaptive Kalman Filter)’ requires 4 iterations. This requirement conflicts with 1, the number of iterations expected by another input/output signal of this subsystem.
I am getting this error as i have build battery pack from battery builder and connecting the block shows this error. check image matlab, simscape, simulink MATLAB Answers — New Questions
How i can write equations in matrix way, for example: A = [2x+4y 2y+3x ; 2x+y 3x^2+2y] [x1 ; x2 ] B = [6x+4y 5y+2x ; 4x+3y 2x^2+3y] [u1 ; u2] is like state-space, but i found the partial derivative only need arrange in matrix way.
A = [2x+4y 2y+3x ; 2x+y 3x^2+2y] [x1 ; x2 ]
B = [6x+4y 5y+2x ; 4x+3y 2x^2+3y] [u1 ; u2]A = [2x+4y 2y+3x ; 2x+y 3x^2+2y] [x1 ; x2 ]
B = [6x+4y 5y+2x ; 4x+3y 2x^2+3y] [u1 ; u2] A = [2x+4y 2y+3x ; 2x+y 3x^2+2y] [x1 ; x2 ]
B = [6x+4y 5y+2x ; 4x+3y 2x^2+3y] [u1 ; u2] matrix array, state-space, derivative partial MATLAB Answers — New Questions
Using Coulomb Counting Method for SoC Estimation of battery
Hi There
I would like to ask if any one could help in turing this into a MATLAB script. Where there Battery voltage and current capacity is asked along with the hours used and then those inputs is used to calculte the state of charge. some thing like what is shown in the picture.
ThanksHi There
I would like to ask if any one could help in turing this into a MATLAB script. Where there Battery voltage and current capacity is asked along with the hours used and then those inputs is used to calculte the state of charge. some thing like what is shown in the picture.
Thanks Hi There
I would like to ask if any one could help in turing this into a MATLAB script. Where there Battery voltage and current capacity is asked along with the hours used and then those inputs is used to calculte the state of charge. some thing like what is shown in the picture.
Thanks battery_system_management MATLAB Answers — New Questions
I need help with an error I get
I have to write a bit of code for an assignment and I keep getting an error and I dont know how to solve it.
I have to determine the position, velocity and acceleration. funcao_forca is a function of a force that is defined in another script. It keeps telling me that F is not recognized. How do I go about this?
function [posicao, velocidade, aceleracao] = atleta(t, f, M)
f = funcao_forca(t,F);
dt = 1;
t1 = [0:dt:t];
aceleracao = zeros(size(t1));
aceleracao = f/M;
velocidade = zeros(size(t1));
for i = 2:length(t1)
velocidade(i) = velocidade(i-1) + aceleracao(i) * (t1(i) – t1(i-1));
end
posicao = zeros(size(t1));
for i = 2:length(t1)
posicao(i) = posicao(i-1) + velocidade(i-1) + 0.5 * aceleracao(i) * (t1(i) – t1(i-1))^2;
end
endI have to write a bit of code for an assignment and I keep getting an error and I dont know how to solve it.
I have to determine the position, velocity and acceleration. funcao_forca is a function of a force that is defined in another script. It keeps telling me that F is not recognized. How do I go about this?
function [posicao, velocidade, aceleracao] = atleta(t, f, M)
f = funcao_forca(t,F);
dt = 1;
t1 = [0:dt:t];
aceleracao = zeros(size(t1));
aceleracao = f/M;
velocidade = zeros(size(t1));
for i = 2:length(t1)
velocidade(i) = velocidade(i-1) + aceleracao(i) * (t1(i) – t1(i-1));
end
posicao = zeros(size(t1));
for i = 2:length(t1)
posicao(i) = posicao(i-1) + velocidade(i-1) + 0.5 * aceleracao(i) * (t1(i) – t1(i-1))^2;
end
end I have to write a bit of code for an assignment and I keep getting an error and I dont know how to solve it.
I have to determine the position, velocity and acceleration. funcao_forca is a function of a force that is defined in another script. It keeps telling me that F is not recognized. How do I go about this?
function [posicao, velocidade, aceleracao] = atleta(t, f, M)
f = funcao_forca(t,F);
dt = 1;
t1 = [0:dt:t];
aceleracao = zeros(size(t1));
aceleracao = f/M;
velocidade = zeros(size(t1));
for i = 2:length(t1)
velocidade(i) = velocidade(i-1) + aceleracao(i) * (t1(i) – t1(i-1));
end
posicao = zeros(size(t1));
for i = 2:length(t1)
posicao(i) = posicao(i-1) + velocidade(i-1) + 0.5 * aceleracao(i) * (t1(i) – t1(i-1))^2;
end
end code, help, error MATLAB Answers — New Questions
Examples of Simulink models of spacecraft subsystems controlled by FPGA algorithms
According to the documentation, Matlab/Simulink provides a number of tools for developing spacecraft systems. Among them, keywords such as: Satellite Communications Toolbox, Building Satellite Communication Systems, Satellite Scenario Modeling, SatCom Link Simulation, Model Spacecraft, Satellite Mission Analysis.
According to this link [MATLAB and Simulink for Space Systems], we can also use Matlab and Simulink for "Analyze RF and digital communications subsystems and deploy the algorithms on FPGAs".
I would like to use some of these tools, as well as models of spacecraft subsystems, to debug and simulate FPGA algorithms.
Unfortunately, I did not find examples of such models and tutorials in the documentation and other sources. Can anyone help me with this and suggest some good examples of spacecraft subsystem models controlled by FPGA algorithms?According to the documentation, Matlab/Simulink provides a number of tools for developing spacecraft systems. Among them, keywords such as: Satellite Communications Toolbox, Building Satellite Communication Systems, Satellite Scenario Modeling, SatCom Link Simulation, Model Spacecraft, Satellite Mission Analysis.
According to this link [MATLAB and Simulink for Space Systems], we can also use Matlab and Simulink for "Analyze RF and digital communications subsystems and deploy the algorithms on FPGAs".
I would like to use some of these tools, as well as models of spacecraft subsystems, to debug and simulate FPGA algorithms.
Unfortunately, I did not find examples of such models and tutorials in the documentation and other sources. Can anyone help me with this and suggest some good examples of spacecraft subsystem models controlled by FPGA algorithms? According to the documentation, Matlab/Simulink provides a number of tools for developing spacecraft systems. Among them, keywords such as: Satellite Communications Toolbox, Building Satellite Communication Systems, Satellite Scenario Modeling, SatCom Link Simulation, Model Spacecraft, Satellite Mission Analysis.
According to this link [MATLAB and Simulink for Space Systems], we can also use Matlab and Simulink for "Analyze RF and digital communications subsystems and deploy the algorithms on FPGAs".
I would like to use some of these tools, as well as models of spacecraft subsystems, to debug and simulate FPGA algorithms.
Unfortunately, I did not find examples of such models and tutorials in the documentation and other sources. Can anyone help me with this and suggest some good examples of spacecraft subsystem models controlled by FPGA algorithms? matlab, simulink, spacecraft, fpga, pld, satellite MATLAB Answers — New Questions
When multiplying or dividing a vector by a scaler, when do you need a period before the operator?
This was a question I had, the picture of the problem and the correct answer is attached, thanks.This was a question I had, the picture of the problem and the correct answer is attached, thanks. This was a question I had, the picture of the problem and the correct answer is attached, thanks. vector, scaler, problem MATLAB Answers — New Questions
Problem to connect external webcam on raspberry pi
When trying to connect the raspi camera in matlab I get the following error: Seed must be a double scalar.When trying to connect the raspi camera in matlab I get the following error: Seed must be a double scalar. When trying to connect the raspi camera in matlab I get the following error: Seed must be a double scalar. raspberry pi, camera MATLAB Answers — New Questions
how to convert logical array in arraycell
logical2cellstr not working..there is a similar words reserved?logical2cellstr not working..there is a similar words reserved? logical2cellstr not working..there is a similar words reserved? how to convert logical array in arraycell MATLAB Answers — New Questions
how to use local parameter in HDL Coder toolbox?
Dear MATLAB Support Team,
I am currently working on developing an UART transmitter block in Simulink. Within this block, I require two parameters: CLOCK_FREQ and BAUD_RATE, which are essential for calculating the DIVIDER parameter, given by CLOCK_FREQ / BAUD_RATE.
While I have learned how to generate parameters using HDL Coder, I am facing confusion regarding the generation of the local parameter DIVIDER, which will be utilized within a counter block. I aim to produce Verilog code similar to the following:
– – – – – – – –
parameter BAUD_RATE = 9600;
parameter CLOCK_FREQ = 100000000;
localparam DIVIDER = CLOCK_FREQ / BAUD_RATE;
if (clk_divider == DIVIDER) begin
// Further implementation
end
– – – – – – – – –
However, the generated code I am obtaining differs:
– – – – – – – – – – – –
parameter integer BAUD_RATE = 9600;
parameter integer CLOCK_FREQ = 100000000;
assign DIVIDER_out1 = 32’b00000000000000000010100010110001;
– – – – – – – – – – –
How can I use BAUD_RATE and CLOCK_FREQ within the module to generate other parameters?
The Constant Block setting is as follows:Dear MATLAB Support Team,
I am currently working on developing an UART transmitter block in Simulink. Within this block, I require two parameters: CLOCK_FREQ and BAUD_RATE, which are essential for calculating the DIVIDER parameter, given by CLOCK_FREQ / BAUD_RATE.
While I have learned how to generate parameters using HDL Coder, I am facing confusion regarding the generation of the local parameter DIVIDER, which will be utilized within a counter block. I aim to produce Verilog code similar to the following:
– – – – – – – –
parameter BAUD_RATE = 9600;
parameter CLOCK_FREQ = 100000000;
localparam DIVIDER = CLOCK_FREQ / BAUD_RATE;
if (clk_divider == DIVIDER) begin
// Further implementation
end
– – – – – – – – –
However, the generated code I am obtaining differs:
– – – – – – – – – – – –
parameter integer BAUD_RATE = 9600;
parameter integer CLOCK_FREQ = 100000000;
assign DIVIDER_out1 = 32’b00000000000000000010100010110001;
– – – – – – – – – – –
How can I use BAUD_RATE and CLOCK_FREQ within the module to generate other parameters?
The Constant Block setting is as follows: Dear MATLAB Support Team,
I am currently working on developing an UART transmitter block in Simulink. Within this block, I require two parameters: CLOCK_FREQ and BAUD_RATE, which are essential for calculating the DIVIDER parameter, given by CLOCK_FREQ / BAUD_RATE.
While I have learned how to generate parameters using HDL Coder, I am facing confusion regarding the generation of the local parameter DIVIDER, which will be utilized within a counter block. I aim to produce Verilog code similar to the following:
– – – – – – – –
parameter BAUD_RATE = 9600;
parameter CLOCK_FREQ = 100000000;
localparam DIVIDER = CLOCK_FREQ / BAUD_RATE;
if (clk_divider == DIVIDER) begin
// Further implementation
end
– – – – – – – – –
However, the generated code I am obtaining differs:
– – – – – – – – – – – –
parameter integer BAUD_RATE = 9600;
parameter integer CLOCK_FREQ = 100000000;
assign DIVIDER_out1 = 32’b00000000000000000010100010110001;
– – – – – – – – – – –
How can I use BAUD_RATE and CLOCK_FREQ within the module to generate other parameters?
The Constant Block setting is as follows: hdl coder, simulink, verilog MATLAB Answers — New Questions
Creating MP4 with Audio
Hello
I want to create an MP4 file which contains audio. VideoWriter is not suitable, as it doesn’t input any audio data. So, I used _vision.VideoFileWriter_ and _step_. But I have some problems.
When running the code below:
videoFWriter = vision.VideoFileWriter(‘Test.mp4’, ‘FileFormat’, ‘MPEG4’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
I receive the following warning message:
Warning: The AudioInputPort property is not relevant in this configuration of the System object.
When I change the code to the following, the video format is uncompressed AVI, which leads to huge file sizes.
videoFWriter = vision.VideoFileWriter(‘Test.avi’, ‘FileFormat’, ‘AVI’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
step(videoFWriter, FrameScreen, FrameAudio);
_FrameAudio_ contains audio data corresponding to one video frame. It seems that it ignores ‘MJPEG Compressor’.
I would love to be able to directly create .mp4 files, but if not possible, it is fine with me to create good quality compressed .avi files, and use a 3rd party software to convert to .mp4. I would appreciate any suggestions. Thanks.
My OS is Windows 7, and MATLAB r2017b.
Cheers
Amir-HomayounHello
I want to create an MP4 file which contains audio. VideoWriter is not suitable, as it doesn’t input any audio data. So, I used _vision.VideoFileWriter_ and _step_. But I have some problems.
When running the code below:
videoFWriter = vision.VideoFileWriter(‘Test.mp4’, ‘FileFormat’, ‘MPEG4’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
I receive the following warning message:
Warning: The AudioInputPort property is not relevant in this configuration of the System object.
When I change the code to the following, the video format is uncompressed AVI, which leads to huge file sizes.
videoFWriter = vision.VideoFileWriter(‘Test.avi’, ‘FileFormat’, ‘AVI’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
step(videoFWriter, FrameScreen, FrameAudio);
_FrameAudio_ contains audio data corresponding to one video frame. It seems that it ignores ‘MJPEG Compressor’.
I would love to be able to directly create .mp4 files, but if not possible, it is fine with me to create good quality compressed .avi files, and use a 3rd party software to convert to .mp4. I would appreciate any suggestions. Thanks.
My OS is Windows 7, and MATLAB r2017b.
Cheers
Amir-Homayoun Hello
I want to create an MP4 file which contains audio. VideoWriter is not suitable, as it doesn’t input any audio data. So, I used _vision.VideoFileWriter_ and _step_. But I have some problems.
When running the code below:
videoFWriter = vision.VideoFileWriter(‘Test.mp4’, ‘FileFormat’, ‘MPEG4’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
I receive the following warning message:
Warning: The AudioInputPort property is not relevant in this configuration of the System object.
When I change the code to the following, the video format is uncompressed AVI, which leads to huge file sizes.
videoFWriter = vision.VideoFileWriter(‘Test.avi’, ‘FileFormat’, ‘AVI’, ‘FrameRate’, 30, ‘AudioInputPort’, true);
videoFWriter.VideoCompressor = ‘MJPEG Compressor’;
step(videoFWriter, FrameScreen, FrameAudio);
_FrameAudio_ contains audio data corresponding to one video frame. It seems that it ignores ‘MJPEG Compressor’.
I would love to be able to directly create .mp4 files, but if not possible, it is fine with me to create good quality compressed .avi files, and use a 3rd party software to convert to .mp4. I would appreciate any suggestions. Thanks.
My OS is Windows 7, and MATLAB r2017b.
Cheers
Amir-Homayoun mp4, audio, compression, video, avi, movie, mpeg4, videofilewriter, videowriter, sound MATLAB Answers — New Questions