Increasing Simulation Speed
Ways to Increase Simulation Speed
Once you have selected the proper method (continuous, discrete, or phasor), solver type, and parameters, there are additional steps you can take to optimize your simulation speed.
Discretizing your electric circuit and your control system. You can even use a larger sample time for the control system, provided that it is a multiple of the smallest sample time.
If you are simulating repeatedly from a particular operating point, specify a vector of initial states:
Simulate your model. Save the initial states as a vector in the MATLAB® workspace.
In Simulink®, in the Modeling tab, select Model Settings > Model Settings.
In the left pane of the Configuration Parameters dialog box, select Data Import/Export.
Select the Initial state parameter and enter the name of the workspace variable that contains the vector of initial states.
Reducing the number of open scopes and the number of points saved in the scope also helps in reducing the simulation time.
Using the Simulink Accelerator mode. The performance gain obtained with the Accelerator varies with the size and complexity of your model. Typically you can expect performance improvements by factors of two to 10.
Using Accelerator Mode and Simulink Coder
The Accelerator mode speeds up the execution of Simulink models by replacing the interpreted M code running beneath the Simulink blocks with compiled code as your model executes. The Accelerator mode uses portions of Simulink Coder™ to generate this code on the fly. Although the Accelerator mode uses this technology, Simulink Coder is not required to run it. Also, if you do not have your own C compiler installed, you can use the LCC compiler provided with your MATLAB installation.
To take full advantage of the performance enhancements made possible by converting your models to code, you must use Simulink Coder software to generate standalone C code. You can then compile and run this code and, with Simulink Real-Time™ software, also run it on a target PC operating the Simulink Real-Time real-time kernel.