Creating a standalone .exe of an .m file that calls a simulink model
124 views (last 30 days)
I have a .m file that controls a gui. A slider in the gui is used as input for a simulink model. My goal is to create a standalone of this whole application, that runs on a PC where neither Matlab nor Simulink are installed.
My approach so far is to generate a standalone .exe out of the simulink model, modify the .m script to pass the input values to this .exe and get the output values, and then generate a .exe out of the .m script.
I have several questions on how to do this:
- Is this the correct approach or would it be better to create a dll out of the simulink model?
- If this is the way to go, which target in the code generation allows the easiest passing of values to the simulink model .exe? I found three different options: ert_shrlib (host based shared library), grt (Generic Realtime Target) and rsim (Rapid Simulation Target). Which of these should I use?
- Are there any step-by-step instructions on how to accomplish this? Or even examples of a similar project?
Thanks you very much!
Saurabh Gupta on 21 Jul 2017
One way would be to generate code from MATLAB Code and Simulink model independently, integrate them manually and compile them together into an EXE. But since GUI related functions are generally not supported by MATLAB Coder, this approach may not work.
You could try the following approach:
1) generate shared library from the Simulink model, then write C/C++ Application Code as a wrapper to pass input/parameter values,
2) create a MEX file ,
3) call it in your MATLAB Code and
All the best!
More Answers (3)
Ewoud Meijvogel on 6 Mar 2019
Hey @Saurabh Gupta,
I have stumbled into to same situation. Is this approach worth taking a shot.
Have you been succesfull in making a standalone?
Thank you in advance,
Lars Risbo on 8 Nov 2018
Do you have a complete example that I can follow? I have no idea on how to write the wrapper code. I have seen such an example somewhere but the link has gone bad.