How computationally intensive are switch case action blocks in Simulink?
1 次查看(过去 30 天)
显示 更早的评论
So I need to switch between different linear models based on a switch condition and computational load is a big concern for my application. I was wondering, does anyone know how costly it is to implement these switch case action blocks?:
https://www.mathworks.com/help/simulink/slref/switchcaseactionsubsystem.html
I was thinking of having a ton of them in the model but only selecting a few based on a switch condition. Like a switch case in code, does having more of these switch action blocks not matter in terms of the computational load of checking them? Like if I had 190 different switch action blocks, the simulink simulation wouldnt check all 190 action blocks to see if it would run them, and rather it would just directly go and simulate the ones the switch case selects? I was hoping this would be the case, but I would much rather check before implementing the 190ish switch case action blocks I need.
0 个评论
采纳的回答
Fangjun Jiang
2024-4-9
Yes. More cases will not increase the computation load. Only the activated cases will be executed. It is called the Condtionally Executed Subsystem.
However, 190ish cases are extream. I would not implement like that in Simulink. Explain the need. There might be a better solution.
3 个评论
Fangjun Jiang
2024-4-9
"at all times I usually need to be running 4 out of the 190 linear models at a time while only selecting the output of 1 of them, and which models are selected for running or for their output varies based on my current operating condition."
I think I understand the need.
I would suggest using a MATLAB Function block. Basically, you would "code" whatever you want to do. Implementing 190ish LTIs using block diagram would be hard to manage.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!