How can I create a stateflow State Transition Table from scirpt?
2 次查看(过去 30 天)
显示 更早的评论
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!