How can I create a stateflow State Transition Table from scirpt?
1 回表示 (過去 30 日間)
古いコメントを表示
Nicolò Badodi
2018 年 12 月 7 日
回答済み: Basavalingappa Mudhol
2018 年 12 月 7 日
Hi, I'm trying to create a MATLAB script that generates a stateflow State Transition Table in the StateMachineSimulator simulink model.
I managed to create the table as a simulink block using the code:
load_system('sflib'); %Loads the stateflow library
load_system('StateMachineSimulator'); %loads my Simulink model
BlockName = 'Test';
block = add_block('sflib/State Transition Table', BlockName); %generates the block
this creates the Transition Table, but then I'm unable to set states and conditions inside it. I thied with:
rt = sfroot; %acccess to the root of all the open simulink objcets
m = rt.find('-isa', 'Simulink.BlockDiagram',...
'-and', 'Name', 'StateMachineSimulator'); %searching the Simulink Model
ch = m.find('-isa', 'Stateflow.StateTransitionTableChart', '-and', 'Name', blockName); %searching for the stateflow chart
which retrieves the handle to the State Transition Table object, and:
state = Stateflow.State(ch); %creates a state in the ch object (my table)
state.Name = 'NotNormal'; %names the state
but what i get is that the state do not appear in the State Transition Table, but appears in the chart when I convert the table into a chart, like shown in the figure:
What am I doing wrong?
Is it actually possible to create State Transition Tables from script?
Thanks in advance for your answer.
I'm using R2014a
0 件のコメント
採用された回答
Basavalingappa Mudhol
2018 年 12 月 7 日
May be you can use this command to create new truth table
truth_table_new = Stateflow.TruthTable(parent)
Or can be looked in the link below
https://se.mathworks.com/help/stateflow/api/stateflow.truthtable.html
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!