Transition from one Sub State to Another State

3 次查看(过去 30 天)
Hi All
I have two States
State A and State B
In State A there is one more State A1
In State B there are two more Sub State State B1 and B2
Output of B1 State has two values say x=2,x=3
When x=2 it Will transition to B2,
But When x=3 it should transition to State A1,
PLease can anyone tell which condition to add to transition to State A1
  1 个评论
Muthukumar Ganesan
Muthukumar Ganesan 2022-10-25
Hi,
There is an ambiguity in your question. What do you refer by output of State B1 ?
Please clarify to help you better
Thanks

请先登录,再进行评论。

回答(1 个)

Purvaja
Purvaja 2025-4-3
Hey @Rithik,
I see that you want to change states with certain conditions. Transition from a sub state in a state to another sub state in another state will be similar to transition from a sub state to another sub state within same state. So, therefore we can simply use transition condition on transition arrows to change sub-states.
I have created the following dummy model as per the requirements given in question. There are 2 states “A” and “B”, with sub states, “A1”,”B1”,“B2” accordingly. State B1 inside state B has default transition, that uses the input given to the entire stateflow chart. There is an if-else condition that produces output x based on the input fed to the stateflow chart. And hence based on this output next state is determined.
Refer to the below diagrams for a better clarifications on the stateflow chart and how the result is achieved:
  • Simulink Model consisting of dummy signals, showing input and output of “Stateflow” block:
  • Stateflow diagram indicating states and sub-states, along with transition conditions:
For more information, kindly refer to the following MathWorks documentations:
  1. Stateflow: https://www.mathworks.com/help/stateflow/getting-started.html
  2. Transition Between operating modes: https://www.mathworks.com/help/stateflow/ug/transitions.html
To access the documentation for the MATLAB release you are using, please execute the following command in the MATLAB command window:
web(fullfile(docroot, 'stateflow/getting-started.html'))
web(fullfile(docroot, 'stateflow/ug/transitions.html'))
Hope this helps!

类别

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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by