MATLAB: Can I access Stateflow chart data in Simulink Functions without passing it as an input to the Simulink function

accesssimulinkstateflow

Can I access Stateflow chart data in Simulink Functions without passing it as an input to the Simulink function?

Best Answer

Typically no, because Simulink Functions are an independent entity inside the Stateflow chart.
However, Simulink Functions can access data with scope Data Store Memory.
1. Using the Symbols pane (View > Symbols) and the Property Inspector (View > Property Inspector), set the scope of the variable you want to access from Stateflow chart as Data Store Memory.
2. Add a Data Store Memory block to the Simulink model that parents the chart.
3. Add a Data Store Read block in the Simulink function inside the chart to read this data.
For more information, see the following documentation: