MATLAB Compiler: sim() in app.Designer Standalone

7 次查看(过去 30 天)
Hello,
i own the Matlab Compiler aswell as the Simulink Compiler Toolbox for the Standalone application.
I tried to create a Standalone-exe from an app.Designer file which includes a call to a Simulink File :
simulation='Simulink-model.slx';
parameter={...};
for i = 1:length(parameter)
app.simin=app.simin.setVariable(parameter{i,1},parameter{i,2},"Workspace",app.simulation);
end
app.simin=Simulink.SimulationInput(app.simulation);
app.simout=sim(app.simin);
The execution with the app.Designer works and calls the Simulink Model as intendend.
Now i want to create a standalone-exe but the Matlab compiler is not recognising the Simulink-Model (i already added the Model to the required files) and outputs an error during compiling:
Could not find any Simulink model file in the static code analysis.
Would be great if smb has a solution for it
thx in advance
stay healthy

回答(1 个)

Sherif Tolba
Sherif Tolba 2021-7-14
I understand that you are getting an error about the model not being found during static code analysis. I noticed a few issues in the code that you shared in your question. Try making these changes and see if this will help:
  • On this line:
simulation = 'Simulink-model.slx';
model extension is redundant. Also, model name should be a valid variable name. Please change it to:
simulation = 'Simulink_model';
  • This line should be moved before the loop:
app.simin = Simulink.SimulationInput(app.simulation);
  • There is no need to explicitly add the model to required files. The way static analysis picks up a model is if the model is typed as a literal string when constructing a SimulationInput object. For example:
app.simin = Simulink.SimulationInput('Simulink_model');
Alternatively, you can place a %#function pragma somewhere in your app's code to let static code analysis know that you are using this model and it will add it for you:
%#function Simulink_model
Thanks,
Sherif

类别

Help CenterFile Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by