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 CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by