MATLAB Answers


Simulink model takes lot of time to save

Asked by Bhargav Kinnal on 24 Jun 2019
Latest activity Answered by Jesús Zambrano on 25 Aug 2019 at 16:19
I have this relatively large simulink model. I make very tiny changes and when i try to save it takes unbelievably long time to finish saving.
I have tried Save_system and also saving via the button.
The model takes forever to save. The model is yet to save while i write this question (Thats about 45mins already!!!!)
Is there anything wrong in my settings? Do i need to clear some matlab or model related files and retry?
A quick help would be really helpful


Are you using a Simulink library? I have experienced issues myself when trying to save a Simulink model after I have opened and unlocked a library. It then actually saves the models, but it keeps on showing the 'Saving' waitbar and I have to kill Matlab and restart it to work again.
I thought so too and killed Matlab twice or thrice to see that it was infact not saved.
What worked for me is an Update diagram and then a save_system.
I still dont know the root cause for this though. And the Matlab help is badly documented for these kind of errors.

Sign in to comment.




1 Answer

Answer by Jesús Zambrano on 25 Aug 2019 at 16:19

Hi Barghav,
Please find below some recommendations you can find in the MathWorks documentation:
Modifying and Simplifying Your Model
Most of the techniques described so far require few, if any, changes to the model itself. You can achieve additional performance improvements by applying techniques that involve modifications to the model.
Accelerating the Initialization Phase
Large images and complex graphics take a long time to load and render. As a result, masked blocks that contain images might make your model less responsive. To accelerate the initialization phase of a simulation, remove complex drawings and images. If you don't want to remove an image, you can still improve performance by replacing it with a smaller, low-resolution version. To do this, use the Mask Editor and edit the icon drawing commands to change the image that is loaded by the call to image().
When you update or open a model, Simulink runs the mask initialization code. If you have complicated mask initialization commands that contain many calls to set_param, consider consolidating consecutive calls to set_param()into a single call with multiple argument pairs. This can reduce the overhead associated with these calls.
Learn more about mask code execution.
If you use MATLAB scripts to load and initialize data, you can often improve performance by loading MAT-files instead. The drawback is that the data in a MAT-file is not in a human-readable form, and can therefore be more difficult to work with than a script. However, load typically initializes data much more quickly than the equivalent script.
Reducing Model Complexity
Simplifying your model without sacrificing fidelity is an effective way to improve simulation performance. Here are three ways to reduce model complexity.
Replace a subsystem with a lower-fidelity alternative. In many cases, you can simplify your model by replacing a complex subsystem model with one of the following:
  • A linear or nonlinear dynamic model created from measured input-output data using System Identification Toolbox
  • A high-fidelity, nonlinear statistical model created using Model-Based Calibration Toolbox
  • A linear model created using Simulink Control Design
  • A lookup table
You can maintain both representations of the subsystem in a library and use variant subsystems to manage them.
Reduce the number of blocks. When you reduce the number of blocks in your model, fewer blocks will need to be updated during simulations, leading to faster simulation runs. Vectorization is one way to reduce your block count. For example, if you have several parallel signals that undergo a similar set of computations, try combining them into a vector and performing a single computation. Another way is to simply enable the Block Reduction optimization in the Optimization > General section of the configuration parameters.
Use frame-based processing. In frame-based processing, samples are processed in batches instead of one at a time. If your model includes an analog-to-digital converter, for example, you can collect the output samples in a buffer and process the buffer with a single operation, such as a fast Fourier transform. Processing data in chunks in this way reduces the number of times that blocks in your model must be invoked. In general, scheduling overhead decreases as frame size increases. However, larger frames consume more memory, and memory limitations can adversely affect the performance of complex models. Experiment with different frame sizes to find one that maximizes the performance benefit of frame-based processing without causing memory issues.
Hope these tips can help you!


Sign in to comment.