Run your application with Accelerator or Rapid Accelerator instead of Normal mode. Be aware that some scopes do not plot data when run in Rapid Accelerator mode.
When using accelerator or rapid accelerator mode, on the Model Configuration Parameters dialog box, search for Compiler optimization level, then set the parameter value to Optimizations on (faster runs).
Use frame-based processing. With frame-based processing, the model processes multiple samples during a single execution call to a block. Consider using frame sizes from roughly 100 to several thousand.
In Model Configuration Parameters > Data Import/Export, turn off all logging.
The model should be single-rate. If the model requires resampling, then choose rational coefficients that will keep the model single-rate.
Do not add any Buffer blocks to the model. If you want to create convenient frame sizes, do it in your data sources. Using a Buffer block typically degrades performance.
Avoid feedback loops. Typically, such loops imply scalar processing, which will slow down the model considerably.
Avoid using scopes. To visualize your data, send it to a workspace variable and post-process it.
If your model has Constant blocks with values that
do not change during simulation, make sure that the sample time is
If you are generating code from the model, set the Solver setting to Fixed-step/ discrete. Set tasking mode to SingleTasking.
You can generate a standalone executable for your Simulink® model to improve performance. The generated code runs without Simulink in the loop. To perform any code generation, you must have an appropriate compiler installed. See https://www.mathworks.com/support/compilers/ for a list of supported compilers.
You can generate generic real-time target (GRT) code if you
have a Simulink
Coder™ license. To do so, set Model Configuration Parameters > Code
Generation > System target file to
grt.tlc (Generic Real-Time Target).
When you generate code for any target (not just GRT),
uncheck the Model Configuration Parameters > Hardware Implementation > Test
hardware > Test hardware is the same as production
hardware checkbox. After the checkbox is
unchecked, set the Device type popup to
MATLAB Host Computer.
You can create generated code with a smaller stack
then the GRT code if you have an Embedded Coder® license. To do
so, set the Model Configuration Parameters > Code Generation > System target
ert.tlc (Embedded Coder).
Then, add the following lines to the Model
Configuration Parameters > Code Generation > Custom Code > Include custom
C code in generated: > Source file edit field:
#include <stdio.h> #include <stdlib.h>