do stateflow support Vector State Machine Judgment
1 回表示 (過去 30 日間)
古いコメントを表示
HI! man&madam:
I'm working on a design for a group of devices that perform the same control strategy based on their terminal voltages, i.e., normal control strategy when the voltage is above a threshold, and fault strategy when the voltage is below a threshold, so I'd like to build a state flow model for control and easy for others to understand, but I'm having trouble outputting the corresponding unit states, and I've tried to add state{idx}=0; to make it a vector instead of a state. How do I set the state so that it is a vector instead, I tried to add state{idx}=0; to initialize it but the system says idx cannot be defined.
I uploaded a demo with three elements and his current output is correct, but the state is one-dimensional data.
Thank you for all!
採用された回答
Alan
2024 年 7 月 5 日
Hi Dai,
I’m not able to understand the transition logic you used in the Stateflow diagram. "Vt" is a vector and you put transition conditions “Vt<0.9” and “Vt>=0.9”.
The above figure contains 3-scopes:
- Scope2: Plots the voltage ‘Vt’
- StateVector: I’ll explain this later
- Scope1: Plots the state
As you can see in Scope2, at T=1, Vt = [0.5 1 0.3]
Vt < 0.9 will result in [1 0 1]
And, according to the window named Scope 1, state=0. This indicates that Stateflow only transitions to “state=1” if “Vt < 0.9” gives a result containing 1 in all indices. Since the vector “Vt < 0.9” will contain 3 logical elements, it will take 8 Stateflow blocks (2^3) to indicate each value assumed by the vector, along with a lot of transitions, which could get cumbersome. Instead, I suggest you use a “Relational Operator” block to simplify the logic like this:
The highlighted section contains the blocks I’ve added. The “Relational Operator” block has the operation set to “<”, and the scope named “StateVector” will give the output as shown in the window named “StateVector” as shown in the previous picture. I hope that scope shows your desired output.
For more information on the Relational Operator block, you can refer to the following MathWorks documentation: https://www.mathworks.com/help/simulink/slref/relationaloperator.html
Regards.
2 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!