Creating a standalone .exe of an .m file that calls a simulink model

조회 수: 59 (최근 30일)
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:
  1. Is this the correct approach or would it be better to create a dll out of the simulink model?
  2. 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?
  3. 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
Saurabh Gupta 2017년 7월 21일
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:
3) call it in your MATLAB Code and
All the best!
  댓글 수: 3
Michael D.
Michael D. 2017년 9월 13일
편집: Michael D. 2017년 9월 13일
@ 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
Saurabh Gupta 2017년 10월 12일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Guy Rouleau
Guy Rouleau 2020년 4월 22일
In R2020a, a new product Simulink Compiler has been released to address this exact use case. See an example here.
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2020년 5월 11일
It will work with GUIDE authored UIs. You don't even need to have a UI around the sim if you don't want to as it's separate from the UI...
Of course, you should strongly consider using the GUIDE to App Designer migration tool to upgrade.
Chris P
Chris P 2020년 5월 12일
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.

댓글을 달려면 로그인하십시오.


Ewoud Meijvogel
Ewoud Meijvogel 2019년 3월 6일
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

Lars Risbo
Lars Risbo 2018년 11월 8일
@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
sergio martinez
sergio martinez 2018년 11월 23일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by