do stateflow support Vector State Machine Judgment

1 回表示 (過去 30 日間)
dai bowei
dai bowei 2024 年 6 月 24 日
コメント済み: Alan 2024 年 7 月 5 日
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!
  1 件のコメント
dai bowei
dai bowei 2024 年 6 月 24 日
sorry,the current output is also incorrect,its always under normal control,how can i fix it :(

サインインしてコメントする。

採用された回答

Alan
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:
  1. Scope2: Plots the voltage Vt
  2. StateVector: I’ll explain this later
  3. 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 件のコメント
dai bowei
dai bowei 2024 年 7 月 5 日
Thank you, Alan.
My original idea was to do the vector calculation in state flow with (idx) as index of the loop calculation, but I found that if I set it up this way, matlab suggests that idx must be an external input variable. But this is against my purpose, I want to use one state flow controller to control multiple devices at the same time independently. I've already achieved what I wanted with the matlab fuction module, but the stateflow module makes it easier to show other people what I'm trying to do. Your idea is great too, thanks again!
Alan
Alan 2024 年 7 月 5 日
You're welcome! Glad to hear that you found another solution too.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by