Is there a way to select variant choice using a simulink signal instead of constants?

12 ビュー (過去 30 日間)
Hello, i have a simulink block diagram, that has a logic gives 1 or 2 in the simulation time with given inputs. I want to use this number to select between my varient choices, using the logic output that is changing in simulation time. İ cannot find a way to do it. It wants me to create a constant for variant selection, but it is not a constant number in my case.
  2 件のコメント
Mathieu NOE
Mathieu NOE 2024 年 12 月 17 日
hello
use logical blocks like comparator so your "1 or 2" signal will be converted into logical signals you can use then to select blocks or signals
metehan akinci
metehan akinci 2024 年 12 月 17 日
Variant subsystem block does not have an inport port to let me chosee the varient selection. That is the problem

サインインしてコメントする。

採用された回答

Aravind
Aravind 2024 年 12 月 18 日
It sounds like you are looking to select between two subsystems based on the value of a specific signal.
In the R2023b release, the "Variant Subsystem" block does not support changing the active subsystem during runtime, as the variant expression is evaluated before the simulation begins. However, starting with R2024b, the "Variant Subsystem" block allows for runtime evaluation of the variant control expression, enabling you to switch between subsystems dynamically based on a signal's value. To achieve this, you can set the "Variant control expression" to evaluate based on a variable in the model workspace, and then use the "Parameter Writer" block to dynamically update this variable to match the signal of interest. More details about the "Parameter Writer" block can be found here: https://www.mathworks.com/help/simulink/slref/parameterwriter.html.
When using this method, ensure that the "Variant activation time" parameter of the "Variant Subsystem" block is set to "runtime" and that the "Treat as atomic unit" option is enabled for each subsystem within the "Variant Subsystem" block.
Alternatively, in R2023b, you can use the "If Action Subsystem" block to switch between subsystems based on a signal. This block functions like an if-statement in programming, activating a specific subsystem depending on whether the "If Block" evaluates to true or false. This allows you to use a signal's value to toggle between desired subsystems. For more information on the "If Action Subsystem" block, visit the following documentation page: https://www.mathworks.com/help/releases/R2023b/simulink/slref/ifactionsubsystem.html. You can also refer to an example here.
I hope this clarifies your question.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by