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

1 visualización (últimos 30 días)
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

Respuesta aceptada

Basavalingappa Mudhol
Basavalingappa Mudhol el 7 de Dic. de 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

Más respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by