필터 지우기
필터 지우기

Simulink, how to do conditional execution inside stateflow

조회 수: 165 (최근 30일)
Lennart Vedin
Lennart Vedin 2017년 7월 3일
편집: Akhilesh Mishra 2017년 7월 10일
Our team want to conditional execute code inside one single state. To be executed every execution. I found no applicable examples.
Such as following does not compile:
% code
entry:
x = y;
during:
if a == 12
b = c;
end
Junctions with conditional inside one single state does compile, but will default only execute at entry. To be executed every execution, an arrow outside the state is required and cause all other entry-code to be executed, that is not wanted. It need to be easy-read visible code, not hidden in function call:
In c-code this is simple and common to write. What is the technique in simulink, without creating "fake-states" that is not functionally required states ?

답변 (1개)

Akhilesh Mishra
Akhilesh Mishra 2017년 7월 10일
편집: Akhilesh Mishra 2017년 7월 10일
From my understanding of the question, it seems that you wish to execute some specific conditional code inside a state chart. For your workflow, you can try using sub-states within your main state. This will not require you to run the entire state again for one conditional code. The details on sub-states can be found in the following link -
To understand the transitions in the substates you can refer to the following documentation link- https://www.mathworks.com/help/releases/R2017a/stateflow/ug/moving-between-different-levels-of-hierarchy-with-supertransitions.html#f9-58101
A relevant example can be found in the link mentioned below, where inside the state 'powerOn', there are two sub-states 'up' and 'down'. The state 'powerOn' can have its own code different from the code in sub-states. https://www.mathworks.com/help/stateflow/examples/modeling-a-dc-motor-in-stateflow.html

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by