- Since multiplication is a basic arithmetic operation and "switch" block involves additional control logic and branching, multiplying a signal with a Boolean value determined by comparing another signal to a constant is generally more efficient.
- If you need to limit only one side of a signal, then using an individual "min" or "max" block is more efficient.
- You may try plotting the signals in MATLAB whenever possible instead of opening a "scope".
- You can use the Simulink variant subsystems. Create a variant subsystem that contains the "scope" block and another variant subsystem without the "scope" block. Use a variant control parameter to switch between the two subsystems, enabling or disabling the "scope" as needed.
- Built-in block functions combine multiple operations into a single block, reducing the overall computational load and improving efficiency. Hence these are more efficient compared to individual blocks.
- The use of “Goto”/ “From” blocks does not significantly impact efficiency in terms of simulation performance. However, excessive use of “Goto”/ “From” blocks can make the model harder to understand and maintain.
What are Some General Tips for Making a Simulink model itself more efficient?
31 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
For MATLAB, there's a general rule of trying to vectorize operations to make MATLAB more efficient, and a few other general ways to make MATLAB code run faster.
In Simulink, I'm aware of Model level ways to make things more efficienct (step time changes, disabling zero crossing detection). However, oftentimes I can't use these genral tips - my step size is already on Auto, or I have the maximum step size I can use and get accurate results. Sometimes turning off the zero crossing detection gives me wild, unreleastic results. Also, oddly, sometimes disabling the zero crossing detection has made it run slower.
This question is not asking about those - I don't want to know how to run the existing model more efficiently. I'm asking about how to design the model itself to be more efficient. What are better / more efficient methods?
I'm using the Profiler and it's identifying blocks that are really inefficient, but I don't know what to do to make them more efficient.
Here are a few specific questions I have - but would appreciate any additional insight someone can offer:
- What is more efficient - multiplying a signal with a Boolean value determined by comparing another signal to a constant, or using a switch block with that comparison as the control input?
- What is more efficient if you only need to limit one side of a signal but not both (Min or Max Limit)? A Saturation block with Max as Inf (or Min as -Inf) or an individual Min (or Max) block?
- I need scopes to view the results of my simulation, but they seem to be slowing it down... is there a more efficient way to use them? (I know not to have one open while running the simulation, that definitely slows it down)
- Follow on to #3 - if I sometimes need scopes for debugging, but not in the final model, how can I easily switch them in and out? I could comment them out, I suppose, but I would prefer if I could use some sort of debug parameter on/off to do it.
- Is it more/same/less efficient to use individual blocks vs. built-in block functions for some things? For example, using the "Add Constant" or "Increment Real World" blocks vs. separate constant and sum blocks, using "Gain" block vs. separate constant and product blocks, etc.
- Does using Goto/From instead of directly connecting effect efficiency? (I'm guessing no from profiler information)
0 commentaires
Réponses (1)
Prateekshya
le 5 Sep 2023
As per my understanding you want to know the efficient methods to design a model. This is a very subjective question and depends on the model you want to design.
I hope that helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!