Deploying an app without specifying Simulink model
10 views (last 30 days)
Show older comments
Hi all !
To explain my problem : I'm making an app where my users needs to see step by step the evolution of a train. To do this I use Simulink so they can make a model that correspond to the train they're analyzing. I made a Library so everything is easy for them to use, they just have to put the right block already with the right parameters.
There is in te app all the function to make the train going (with specific equation and parameters that the user is giving himself), and then the app send the information to a Simulink. BUT the simulink is made by the user, so it is not really define in the app. He just choose it with :
[file,path] = uigetfile('*.slx', 'Choisissez un modèle à simuler');
selectedFile = fullfile(path,file);
[pathstr, name, ext] = fileparts(file); %#ok<*ASGLU>
tf = slreportgen.utils.isModelLoaded(name);
if tf == 0
open(selectedFile);
end
app.NomSimulationEditField.Value = name;
app.SimulerButton.Enable = 'on';
Everything works fine when I use :
if app.NomSimulationEditField.Value == ""
msgbox("Le nom de la simulation n'a pas été spécifié");
else
app.SimulationCheckBox.Value = 1;
app.StopButton.Enable = 'on';
simInp = Simulink.SimulationInput(app.NomSimulationEditField.Value);
simInp = simInp.setModelParameter('StopTime', 'inf');
simInp = simInp.setModelParameter('SimulationMode', 'normal');
sim(simInp);
end
As you can see the name of the model is not really specified, this is just the name of the Simulink that the user choose. And because of this I can't make a standalone app, is there any solutions to my problem ? Or this is the limit of my app.
N.B. : Here is the log file error
Error while determining required deployable files. Compilation terminated. Details:
Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('matlab.depfun.internal.Completion/r
equiredComponents', 'C:\Program Files\MATLAB\R2020b\toolbox\matlab\depfun\+matlab\+depfun\+internal\Completion.m', 397)" style="font-weight:bold">matlab.depfun.internal.Completion/requiredComponents</a> (<a href="matlab: opentoline('C:\Program Files\MATLAB\R2020b\toolbox\matlab\depfun\+matlab\+depfun\+internal\Completion.m',397,0)">line 397</a>)
Could not find any Simulink model file in the static code analysis. Specify Simulink model file(s) with %#function pragma in the code or include them as additional files.
0 Comments
Answers (1)
Esther
on 16 Aug 2024
For the compiler to be able to automatically detect the model and its dependencies, the model name must be explicitly passed into the SimulationInput object as a literal value instead of via a variable. This is because mcc does a static analysis of the code to figure out the model being used and if the model name is specified by a variable, static analysis cannot evaluate the variable to determine the model name.
You can either use the %#function pragma or you can explicitly specify the model using the -a option as the error message indicates
Specify Simulink model file(s) with %#function pragma in the code or include them as additional files.
Options 1:
Add the following line somewhere in your script file
%#function modelName
Option 2:
mcc -m scriptName.m -a modelName.slx
0 Comments
See Also
Categories
Find more on Deploy Standalone Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!