How can I create a stateflow State Transition Table from scirpt?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nicolò Badodi
il 7 Dic 2018
Risposto: Basavalingappa Mudhol
il 7 Dic 2018
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/198489/image.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
0 Commenti
Risposta accettata
Basavalingappa Mudhol
il 7 Dic 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
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!