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.

  • Simulating large systems or complex power electronic converters can be time consuming. If you have to repeat several simulations from a particular operating point, you can save time by specifying a vector of initial states in the Simulation > Configuration Parameters > Workspace IO dialog box. This vector of initial conditions must have been saved from a previous simulation run.

  • 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 activate the Accelerator mode, select Simulation > Mode > Accelerator from the toolbar of your model window. Alternatively, you can select Accelerator from the pull-down menu in the model window toolbar.

The following table shows typical performance gains obtained with discretization and Accelerator mode applied to the following two examples: a DC drive using a chopper and the AC-DC converter using a three-phase, three-level voltage-sourced converter. Two versions of the DC drive model are provided as examples shipped with the product: a continuous version, power_dcdrive, and a discrete version, power_dcdrive_disc. The AC-DC converter is available as the power_3levelVSC example.


Simulation Time in Seconds*

Simulation Method

DC drive

(Stop time = 2 s)

AC-DC converter

(Stop time = 0.2 s)

Continuous: ode23tb default parameters



9.0 (Ts = 10 µs)

14.5 (Ts = 5 µs)

Discrete + Accelerator

5.2 (Ts = 10 µs)

3.3 (Ts = 5 µs)

* Simulation times obtained on a Pentium IV 2.6 GHz processor, with 512 MB of RAM

The table shows how discretizing your circuit speeds up the simulation by a factor of 1.33 for the DC drive. Using the Accelerator mode, an additional factor of 1.7 performance gain is obtained. For the AC-DC converter, the Accelerator mode provides a gain of 4.4 times. For complex power electronic converter models, the Accelerator mode provides performance gains up to factors of 15.

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.

Was this topic helpful?