How do I compare all members of a bus/structure at once in Stateflow in R2021a?
6 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2025 年 10 月 17 日 0:00
回答済み: MathWorks Support Team
2025 年 10 月 24 日 15:08
I am using a Stateflow chart that receives a bus (structure) signal. I want to check that all members are nonzero. Currently I write conditions like the following:
AAA.Mem1 != 0 && AAA.Mem2 != 0 && AAA.Mem3 != 0...
Is there a way to compare all members collectively as if they were an array?
採用された回答
MathWorks Support Team
2025 年 10 月 17 日 0:00
Unfortunately, Stateflow does not support the functionality to compare structure members all at once. Therefore, as you mentioned, it is necessary to write conditional expressions for each member individually.
However, if the condition becomes too complex and reduces readability, you can consider using a MATLAB Function block that receives the structure as input and performs the comparison inside the function. With this approach, you can evaluate all members within the function, keeping the Stateflow side concise.
I attached a simple model called "sample_mdl.slx" and the corresponding "sample_sldd.sldd" as a reference for this method. Let us know if this helps!
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!