Creating a standalone .exe of an .m file that calls a simulink model
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Thaddäus Wiedemer
el 19 de Jul. de 2017
Comentada: RANJITH SRIGANESAN
el 25 de Sept. de 2024
Hi,
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!
0 comentarios
Respuesta aceptada
Saurabh Gupta
el 21 de Jul. de 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,
3) call it in your MATLAB Code and
All the best!
3 comentarios
Michael D.
el 13 de Sept. de 2017
Editada: Michael D.
el 13 de Sept. de 2017
@ Saurabh,
I have nearly the same problem like Thaddäus. I have a gui which uses a Simulink modell do create data and I want to create a standalone on windows x84.
My gui uses "sim" to run my Simulink model.
After compiling the gui, I found out that "sim" can not be compiled.
Now I took your way to make my project successful.
I have already generated my shared lib. Could you please explain from which component do I need a mex file ? How can I call mex files to run my simulation from gui? Do you have or know any examples that solve this problems?
I could not find something helpful on the Internet.
Saurabh Gupta
el 12 de Oct. de 2017
Hi Michael,
Only a shared library is not sufficient, you also need to write application code as a wrapper that uses it. Then, mex this combination of application code with the library, and replace the sim calls with the corresponding calls to your MEX API before creating the executable.
Hope this helps!
Más respuestas (3)
Guy Rouleau
el 22 de Abr. de 2020
In R2020a, a new product Simulink Compiler has been released to address this exact use case. See an example here.
4 comentarios
Chris P
el 12 de Mayo de 2020
Great, thanks Sean.
I was wanting to integrate a Simulink model into a GUIDE based analysis tool I was working on a while back, but in speaking to your colleagues found it wasn't possible ...at the time!
I appreciate your suggestion to migrate to App Designer too, but I recall there were some things I wasn't able to do in App Designer that I could with GUIDE, but again, maybe this has moved on since and will add to my to-try list!
Thanks again.
RANJITH SRIGANESAN
el 25 de Sept. de 2024
Hey Chris! I am facing a similar issue.
I have a simulink model which takes inputs from a GUI that i made using the app designer. I want to deploy it as a standalone application with the UI. The user inputs values in the UI and can see the graphical results on the UI.
in my appdesginer code view, i have the following lines of code: The code runs smoothly when i run all these in my MATLABR2023b environment. But ,When I package this as an app and run the same application, My code is not executed beyond the Deployment line. I tried using a logfile to see where it gets stuck and it is the line that shows "Deployment". I clearly hear a bong sound (the error sound) while i run the app. The logfile has "5 before Configured for deployment.." and thats it. No other info is logged into it.
A youtube video showed the same procedure for deploying an app that inlcudes a simulink model. But it doest work somehow. Did you try that procedure and did it work for you. It would be great if you could help.
fprintf(logFile, '4 All values initialised..\n');
fprintf(logFile, '5 before Configured for deployment..\n');
in = simulink().compiler.configureForDeployment(in); %%Deployment
fprintf(logFile, '5 Configured for deployment..\n');
out = sim(in); % Run simulation
out.logsout;
fprintf(logFile, '6 logsout command...\n');
Ewoud Meijvogel
el 6 de Mzo. de 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,
Ewoud Meijvogel
0 comentarios
Lars Risbo
el 8 de Nov. de 2018
@saurabh
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.
Best regards,
Lars
1 comentario
sergio martinez
el 23 de Nov. de 2018
I have the same lack in the solve of the problem, I have no idea how to write the wrapper code, could anyone help us to sucess on it?
Regards
Sergio
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!