Please let me know the best practice for authoring a iterating logic in Simulink.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
One of the problem statement that I work on requires to find an optimal value of a variable at every simulation time step. But the catch is I need to run a iterative routine, for loop in my case at every time step to evaluate the required value of the variable.
Based on my knowledge I had three options:
- Simulink blocks to implement the logic flow (for loop in my case) - Very difficult if the length of the loop is large
- MATLAB function - Easy to implement but dubious on if it is a better choice for hardware deployment/code generation
- Stateflow - Again easy to implement but dubious if it is a better choice for code optimizations/hardware deployment.
0 commentaires
Réponses (1)
Shaunak
le 22 Avr 2025
Modifié(e) : Shaunak
le 23 Avr 2025
Hi Akhil,
As per my understanding, for running an iterative routine at each simulation step, the MATLAB Function block is a practical and flexible choice. It’s efficient for implementing iterative logic and works well for hardware deployment if your code supports code generation. For straightforward iterative optimization, it keeps things simple compared to Stateflow.
If you’re running multiple simulations with only parameter changes (like controller tuning), you might also want to consider using 'parsim' with 'Simulink.SimulationInput'. This approach can speed up your workflow by enabling parallel simulations rather than running them sequentially in a for-loop.
Kindly refer to the MATLAB Answers thread below for more discussion on optimizing iterative Simulink calls:
You can also check out the following MathWorks documentation for 'parsim' here:
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Verification, Validation, and Test dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!