Simulink, how to do conditional execution inside stateflow
153 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 ?
0 commentaires
Réponses (1)
Akhilesh Mishra
le 10 Juil 2017
Modifié(e) : Akhilesh Mishra
le 10 Juil 2017
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
0 commentaires
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!