MATLAB: How to increase simulation speed for Simulink models that have Embedded MATLAB Function blocks

embeddedemlperformancesimulationsimulink

My model has several Embedded MATLAB Function blocks. Is there a way to increase the simulation speed?

Best Answer

For simulation, the debug instrumentation will make Embedded MATLAB a bit slower. Turning off debugging will help the problem.
1. Start model explorer. From Simulink model windows, select "View" -> "Model Explorer".
2. Click on the model name. This should be right below "Configuration Preferences"
3. Click on the Contents window, scroll all the way to the bottom and select "sfun"
4. Click on the "Coder Options" button and uncheck "enable debugging/animation"
If you are using Simulink 6.3 (R14SP3) or later, you can also turn debugging on and off for individual Embedded MATLAB blocks using the Embedded MATLAB Editor. To do so, open the Embedded MATLAB Editor (by double-clicking on the block) and select the "Debug -> Enable Debugging" option to toggle the use of debugging. This option will be greyed out if debugging has been disabled for all Embedded MATLAB blocks using the method described above.