How can I create a stateflow State Transition Table from scirpt?

3 Ansichten (letzte 30 Tage)
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:
Capture.PNG
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

Akzeptierte Antwort

Basavalingappa Mudhol
Basavalingappa Mudhol am 7 Dez. 2018
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

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by