MATLAB Compiler: sim() in app.Designer Standalone

조회 수: 8 (최근 30일)
Florian Daberkow
Florian Daberkow 2021년 1월 26일
답변: Sherif Tolba 2021년 7월 14일
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