Access local symbol in a Simulink-based state in Stateflow

2 次查看(过去 30 天)
I have a simulink-based state in a stateflow chart. Simulink-based states can access input and output symbols (chart symbols) using in and out ports. Is it possible to read or modify the value of a local symbol from a simulink-based state?
Alternatively, how can I trigger a transition from a simulink-based state? The pole-vaulter example uses integrator states, but what about using other signals within the simulink state that are not block states?

采纳的回答

Kanishk
Kanishk 2024-9-19
Hi Francis,
Local symbols in Stateflow cannot be modified in the Simulink based states. Instead, to read/modify values from Stateflow in Simulink based states “Data Store Memory” can be used.
To implement Data Store memory,
  • Place a "Data Store Memory" block in your Simulink model outside of the Stateflow chart. This block will serve as a shared memory resource.
  • Change the "Data type" to "double" and "Signal Type" to "real" of "Data Store Memory" block.
  • In the Stateflow chart, add a data object and configure it as "Data Store Memory" using the Symbols pane. This allows the chart to access the shared memory.
  • Within Simulink-based states, utilize "Data Store Read" and "Data Store Write" blocks to access and modify the shared memory. These blocks enable interaction with the data store memory object.
To trigger transitions based on signals from Simulink-based states, use "Data Store Write" to update the signals in the Data Store Memory object. These updated values can then be used to trigger transitions within the Stateflow chart.
To learn more about “Data Store Memory” and how to access the memory in Stateflow, please go through these official MATLAB documentations:
I am also attaching the example model I created for better understanding.
Hope this helps!
Thanks
  1 个评论
Francis Therien
Francis Therien 2024-9-19
Thank you @Kanishk. This workaround is a bit annoying, but it works. It would be a great addition by Mathworks in future versions of Simulink and Stateflow to provide a mechanism for direct access to local data in charts from Simulink based states.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Complex Logic 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by