Access local symbol in a Simulink-based state in Stateflow

2 ビュー (過去 30 日間)
Francis Therien
Francis Therien 2024 年 9 月 17 日
コメント済み: Francis Therien 2024 年 9 月 19 日
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 Center および File ExchangeComplex Logic についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by