フィルターのクリア

Why my simulation slow to run model that use for each block

2 ビュー (過去 30 日間)
Jean-Tazeb
Jean-Tazeb 2024 年 2 月 7 日
編集済み: Ayush 2024 年 3 月 4 日
I got vehicle model with one wheel and I try to convert it to a four wheel model. To make it happen I used a for each block that represent the wheels in order to make the model simpler since each wheel are the same.
(The block alone on the left was at the position of the 'Wheels' subsystem block)
But for some reason the simulation take long time to perform. So I juste change the model by create 4 instances of wheel instead of the for each block, and this option is way more faster.
(This is insinde subsystem block named 'Wheels')
(This is what the wheel model look like)
Have you got some solution to improve the for each methode performance, because I still prefere this option since its a clearer model and this olso is easier to manipulate.

採用された回答

Ayush
Ayush 2024 年 3 月 4 日
編集済み: Ayush 2024 年 3 月 4 日
Hi Jean,
From the screenshots shared of your model, I can see that the visual representation of the model would be enhanced using “For Each” blocks but that also introduces computational overhead leading to loss in performance. Especially, if the block does not handle parallel processing or complex dynamics of the wheel subsystem. You can refer to some of the suggestions below in order to improve the performance of the model using the “For Each” method:
- Utilize the “Multicore Execution Support” for the “For Each” subsystem which enables multicore execution for faster simulation. It automatically profiles eligible subsystems for parallel processing and speeds up execution time. For more information you can refer to the below documentation:
- Look out for some calculations that are being done within the wheel subsystem that are same across each wheel and does not depend on iteration index in order to move these calculations out of the “For Each” block.
- Pre-allocate arrays and data structures within the “For Each” block or “Wheel Model” subsystem to avoid dynamic memory allocation during simulation. For more information on preallocation and increase in performance, refer to the below documentation:
Hope this helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by