State Flow Run time object

10 visualizaciones (últimos 30 días)
Ajay krishna Vasanthakumar
Ajay krishna Vasanthakumar el 20 de Jul. de 2020
Respondida: Vedant Shah el 20 de Jun. de 2025
Hello all,
is it possible to get the run time object of states and flow diagrams ?
Thanks in Advance,
Ajay Krishna

Respuestas (1)

Vedant Shah
Vedant Shah el 20 de Jun. de 2025
When working with Stateflow in MATLAB, runtime information about states and flow diagrams can be accessed during simulation. MATLAB provides a Stateflow API that enables programmatic interaction with charts, states, transitions, and data.
The sfroot function retrieves the root of the Stateflow hierarchy. From there, the find method can be used to locate the desired model. Once the model is identified, a specific chart can be accessed, and the currently active states can be queried.
A sample code snippet is as shown below:
rt=sfroot;
model=rt.find('-isa','Stateflow.Block','-and','Name','YourChartName');
chart=model.Chart;
activeStates=chart.activeState;
disp(activeStates.Name);
To monitor which state is active at each simulation time step, it is also possible to use a MATLAB Function block or enable data logging to export state information to the workspace.
For more information, please refer to the documentation using the following commands in the MATLAB command line:
web(fullfile(docroot, " /stateflow/ref/sfroot.html "));
web(fullfile(docroot, "/matlab/ref/find.html "));

Categorías

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

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by