How can I change the mode value of a variant subsystem during simulation?

4 visualizaciones (últimos 30 días)
Mihnea
Mihnea el 10 de Jun. de 2014
Respondida: Rajanya el 12 de Feb. de 2025
For example at simulation time 10, the value of mode switches so that another child subsystem is activated?
Thank you

Respuestas (1)

Rajanya
Rajanya el 12 de Feb. de 2025
I don't think this would have been possible for the earlier versions (where using conditional subsystems would have been the best way to go about), but as of MATLAB R2024b, runtime activation time has been added to the 'Variant activation time' in the block parameters of the subsystem.
This can be leveraged in combination with a 'Parameter Writer' block, where the 'Parameter Writer' can be set to write the value of a control variable to the base workspace dynamically. The variant subsystem can be configured to switch based on certain values of the control variable under 'runtime' activation time.
The following setup is provided to demonstrate the same -
Here, as per requirement, the MATLAB function block sets the value of 'y' to 1 if time ('u' here) < 10 and to 2 otherwise. The value of 'y' is recorded by the 'Parameter Writer' to a base workspace variable 'control' (global).
The variant block parameters are set as -
The 'Treat as Atomic' checkbox should also be ticked for the child subsystems.
After configuring as such, the setup successfully switches child subsystems based on the dynamic change of the variant control variable which is controlled by the clock and the MATLAB Function block.
To know more about 'Parameter Writer', you can refer to its documentation page by executing the following command from MATLAB Command Window -
doc Parameter Writer
Hope this helps!

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by