How can I improve the simulation speed of my MATLAB/Simulink model
Show older comments
My Simulink model (2 fuzzy controllers + batteries + converters + droop control) is running very slowly.
What are the best ways to speed it up?
Answers (1)
Soumya
on 27 Mar 2026
0 votes
Hi Sneha,
If a Simulink model consisting of fuzzy controllers, batteries, converters, and droop control is running slowly, the issue is typically related to solver configuration, block implementation, and model structure. Based on MathWorks documentation on the following points should be considered:
- The presence of an 'Interpreted MATLAB Function' block significantly slows simulation because the MATLAB execution engine is invoked at every time step. Wherever possible, such blocks should be replaced with built-in blocks like 'Math Function'.
- If the model contains a MATLAB file 'S-function', it will also degrade performance due to repeated MATLAB engine calls. It is recommended to convert it into a subsystem or a compiled C-MEX S-function.
- The use of a 'Memory' block with variable-step solvers (such as 'ode15s' or 'ode113') forces the solver to reset to first order at each step, which reduces efficiency.
- The maximum step size should not be unnecessarily small. Using the default setting 'auto' is generally recommended unless a smaller step size is required for accuracy.
- Accuracy requirements should not be excessively strict. The default relative tolerance (approximately 0.1%) is sufficient for most models. Very small absolute tolerances can cause the solver to take excessive steps, especially when state values approach zero.
- If the simulation time interval is too long, it increases computation time. Reducing the simulation duration can improve performance.
- For stiff systems (common in models with converters and batteries), a stiff solver such as 'ode15s' should be used. Using a non-stiff solver for such systems can significantly slow down simulation.
- Sample times in the model should be multiples of each other. Non-matching sample times force the solver to take smaller steps to satisfy all sample hits.
- The presence of algebraic loops should be avoided. Algebraic loops require iterative solutions at every time step and can severely degrade simulation performance.
- Feeding a 'Random Number' block into an 'Integrator' block in continuous systems is inefficient. Instead, the 'Band-Limited White Noise' block should be used.
- Scope blocks displaying a large number of data points can slow down simulation. Reducing the number of plotted points or limiting visualization during simulation improves performance.
- When running multiple simulations with parameter changes but no structural modifications, Fast Restart should be used. This avoids recompiling the model for each simulation and significantly reduces total simulation time.
- In models with fuzzy controllers, reducing the number of rules or membership functions can improve computational efficiency.
In summary, simulation speed can be improved by optimizing solver settings, avoiding interpreted or MATLAB-based blocks, ensuring consistent sample times, eliminating algebraic loops, and reducing visualization overhead.
Please refer to the following documentation for more information:
- https://www.mathworks.com/help/simulink/ug/speed-up-simulation.html
- https://www.mathworks.com/help/simulink/ug/choose-a-solver.html
I hope this helps!
Categories
Find more on Simulink Design Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!