One or more output arguments not assigned during call to "sim"

1 次查看(过去 30 天)
Hello support team,
I have created a Java Package from the following MATLAB code:
function DTX_Vibration()
prompt = '\n Enter the bearing speed (100-400 RPM) = \n ';
speed = input(prompt);
y = (0.4/300)*speed;
assignin('base','InputTorque',y);
a = sim('DTX','SaveOutput','on','OutputSaveName','shaft'); % shaft is a 'To Workspace' block in Simulink to capture the timeseries data.
a.find('shaft');
output = a.get('shaft');
assignin('base','output1',output);
T = table(output.time,output.Data,'VariableNames',{'Time-sec','Amplitude-mm'});
plot(output.time,output.Data);
title('Vibration signal from the impacted Bearing in Time Domain');
xlabel('Time');
ylabel('Amplitude');
print('vibrations','-djpeg');
filename = 'vibration_shaft.csv';
writetable(T,filename);
end
when the code is executed in Matlab, it is working fine without any error and creates a csv flie containing the timeseries data obtained from the simulink model 'DTX'.
After creating the java package from the library compiler, I executed it through the Windows command prompt as follwos:
javac -cp DTX_Vibration.jar;"C:/Program Files/MATLAB/MATLAB Runtime/v97/toolbox/javabuilder/jar/javabuilder.jar" DTX_VibrationSample1.java
java -cp .;DTX_Vibration.jar;"C:/Program Files/MATLAB/MATLAB Runtime/v97/toolbox/javabuilder/jar/javabuilder.jar" DTX_VibrationSample1
Then I get the follwing error in the command prompt:
... Matlab M-code Stack Trace ...
com.mathworks.toolbox.javabuilder.MWException: One or more output arguments not assigned during call to "sim".
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclFeval(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$600(MWMCR.java:33)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclFeval(MWMCR.java:897)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$2.invoke(MWMCR.java:784)
at com.sun.proxy.$Proxy0.mclFeval(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.invoke(MWMCR.java:447)
at DTX_Vibration.Class1.DTX_Vibration(Class1.java:227)
at DTX_VibrationSample1.DTX_VibrationExample(DTX_VibrationSample1.java:29)
at DTX_VibrationSample1.main(DTX_VibrationSample1.java:46)
Please help me on how to use the sim command when assigned as shown in the code.
Thanks for your support.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Java Package Integration 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by