Why does my enabled subsystem access parameters although it is disabled?

3 ビュー (過去 30 日間)
Heiko 2016 年 3 月 15 日
回答済み: Vidya Viswanathan 2016 年 4 月 1 日
I have a very simple model consisting only of an Enabled Subsystem which is permanently disabled:
Within the Enabled Subsystem, there is a gain block with gain x, where x is NOT defined in the workspace.
When I run the model, I get "Error evaluating parameter 'Gain' in 'Demo/Enabled Subsystem/Gain' Undefined function or variable 'x'." although the subsystem is obviously disabled.
But why? How can I avoid this error?
Background of my question: I want to avoid simulating unnecessary components of my model, so I put them into an Enabled Subsystem which is dynamically activated by a parameter. If it is disabled, I currently still have to provide its parameters in workspace (represented by x in my minimal example) because otherwise I end up with an error, which is quite annoying.
Thank you for any help. Heiko

回答 (1 件)

Vidya Viswanathan
Vidya Viswanathan 2016 年 4 月 1 日
Hi Heiko,
I am not sure if such an option is available in Simulink. Although that subsystem would not be executed (because it is permanently disabled), when you try to simulate a model, the first step in the process is called model compilation. In this stage, Simulink evaluates all the parameters of the blocks present in the model and determines their value. Only after this check is passed, other steps like performing block reduction optimizations, determining the execution order happen. You could specify Simulink to enable execution of only conditionally active blocks. This comes into play only during the execution of the model and increases the speed of execution. However, you would still be required to specify values of all the parameters in the model.
I hope this answers your query.


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

Community Treasure Hunt

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

Start Hunting!

Translated by