stateflow "if else if else" structure not working properly

17 vues (au cours des 30 derniers jours)
MUSKAN
MUSKAN le 22 Mai 2024
Commenté : Les Beckham le 23 Mai 2024
hi,
I am trying to make a stateflow chart using the if-else-if-else pattern in the tool panel but somehow the conditions aren't followed and it keeps executing the first condition's action even if the that ain't true.
how can I make it consider other conditions as well?
below attached is the screenshot of the same
the output is always "snow and haze" even if the input changes.

Réponse acceptée

Les Beckham
Les Beckham le 22 Mai 2024
Modifié(e) : Les Beckham le 22 Mai 2024
I don't have access to Stateflow so I can't test this, but I know that the compound comparisons that you have shown are not allowed in Matlab, so I suspect that they aren't allowed in Stateflow either. The comparisons have to be done separately, then anded together. So, for example, change 0.90 < y < 0.91 to 0.90 < y & y < 0.91.
An example of why this might not be working for you, using Matlab code:
y = 0.1;
tf = 0.9 < y < 0.91
tf = logical
1
tf2 = 0.9 < y & y < 0.91
tf2 = logical
0
  2 commentaires
MUSKAN
MUSKAN le 23 Mai 2024
works, thanks
Les Beckham
Les Beckham le 23 Mai 2024
You are quite welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by