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

1 次查看(过去 30 天)
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
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.
Regards,
Vidya

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by