Why does as app created in "app installation file to share your app with MATLAB users" run fine but fails to run when created as a "Standalone Desktop app"?

35 views (last 30 days)
I have a model that utilises .slx and .m files and is packaged in a .mlapp application. The simplified version of the model is as follows:
% Load and run the Simulink model
sim('Modeltest1.slx');
% Assign values to the base workspace
Power = 2 * 18;
assignin("base", "Power", Power);
assignin("base", "Power1", Power1);
assignin("base", "Power2", Power2);
The model runs correctly within the MATLAB App. It also functions as expected when an installation file (.mlappinstall) is created in "create an app installation file to share your app with MATLAB users" using the App Designer.
However, in Standalone Desktop App mode, the application compiles without errors and opens successfully but does not execute, and no feedback is provided regarding the failure to run.

Answers (1)

Tejas
Tejas on 26 Mar 2025
Hello Ugo,
The Standalone Desktop Application does not simulate a Simulink model programmatically in the same way the model is simulated programmatically within MATLAB. According to the documentation, a Simulink model can be run outside of MATLAB using the Simulink Compiler.
In this process, the object of 'Simulink.SimulationInput' class is used for simulating the model and modifying values in the base workspace. For more information on this class, refer to this documentation: https://www.mathworks.com/help/releases/R2024a/simulink/slref/simulink.simulationinput.html.
Here is an example on how to simulate a model during deployment:
  • Create an object of the 'Simulink.SimulationInput' class:
simIn = Simulink.SimulationInput(mdlName) ;
  • Assign values to variables in the base workspace:
simIn = simIn.setVariable(simIn,'Power', Power);
  • Simulate the model:
out = sim(simIn);
For detailed guidance on deploying a Simulink model along with App Designer using Simulink Compiler, refer to this documentation: https://www.mathworks.com/help/releases/R2024a/slcompiler/ug/deploy-a-simulation-with-simulink-compiler.html.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!