Filter löschen
Filter löschen

Create dynamic model related to parameters into mask

1 Ansicht (letzte 30 Tage)
Claudio Rosso
Claudio Rosso am 19 Jan. 2024
Kommentiert: Fangjun Jiang am 8 Mär. 2024
Hello everyone,
I would like to create a dynamic subsystem into a library that could change in relation of the parameters I set into the mask.
For example, if I activate a specific flag, i would like to connect an outport to one signal or another one if the flag is deativated.
In pseudo-code will be something like this:
If (flag == 0), out = A
else if(flag !=0), out = B
I know i could just use a switch block using the parameter "flag" for the routing, but i have issue with simulink code inspector because it will give warning because i call the parameters from the mask into a "Constant" block. Moreover, it will help me to reduce the load of the generated code beacuse the partthat is not needed won't be generated.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 20 Jan. 2024
It is possible. However, it becomes complicated when you want to build this into a library block. See "Parameterized Link" for details. Certain model variations can be implemented through a parameter while others can't.
A better way is to use Variant Subsystem. There are also Variant Source and Variant Sink blocks.
  4 Kommentare
Claudio Rosso
Claudio Rosso am 7 Mär. 2024
Bearbeitet: Claudio Rosso am 7 Mär. 2024
I've tried to use source variant to create different configuration, but i have this error:
Error:Propagating variant condition eControlType == TeMathControlType.Multiply outside the scope of its mask workspace is not supported because the condition originates from the mask workspace of block '...'.
I'm using mask parameters to chooose the correct variant path into the block.
Fangjun Jiang
Fangjun Jiang am 8 Mär. 2024
I see your point. Now I found this note.
"The operands that you specify in a condition expression of type Simulink.VariantExpression must be defined in the base workspace or a data dictionary. Specifying operands that are defined in the mask or model workspace is not supported."
You can choose "label" to control the variant. In that way, the dialog of the Variant already looks like a "Mask" with the dropdown list. But of course, you can not combine this with other things that you want to mask.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by