MATLAB Answers


How to create an executable for M-file that intrinsically calls SIMULINK model(i,e, .mdl file) ?

Asked by Control Machine on 25 Jan 2013

I wrote an M-file which loads all the required parameters to workspace required to run the simulation in SIMULINK and loads the results back to workspace. I then use these results to write in a .txt file and for plotting.

Now I want to create a single click executable that combines M-file and SIMULINK model to be used on any Windows machine.

How can I create an executable that of MATLAB file that intrinsically calls SIMULINK model?


1 Answer

Answer by Ryan G
on 28 Jan 2013

Calling Simulink from MATLAB and generating a single executable would be tough if not impossible. The issue being SIM is not a supported command for MATLAB Coder.

However, you could generate an EXE or DLL for the simulink model and call it like you would from a c program using the coder.ceval functions in the MATLAB code.

Realistically the route I would take would be generate an EXE for the model and run the MATLAB code in MATLAB, or deploy it using MATLAB Compiler


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!