Access chart data during simulation
this provides external MATLAB® code, such as functions and apps, access to chart data during simulation.
For charts in Simulink® models, external MATLAB code can access inputs, outputs, and local data.
For standalone charts in MATLAB, external MATLAB code can access local data and call
step, input event functions, and graphical and MATLAB functions in the chart. For more information, see Execute a Standalone Chart.
In charts in Simulink models, the keyword
this is supported only as
an argument to external MATLAB code. Any other use of the keyword in the chart results in a
Connect Chart to MATLAB App
Create a bidirectional connection between a Stateflow® chart and a MATLAB app created in App Designer. Call the app as an extrinsic function
this as an argument to the constructor. In the app,
create a custom property to interface with the chart during simulation. In the
chart, store the value returned by the function call to the app as a local data
In a chart that uses MATLAB as the action language, enter:
coder.extrinsic(appConstructor); app = appConstructor(this);
In a chart that uses C as the action language, enter:
app = ml.appConstructor(this);
Change Data Value While Debugging Standalone Chart
Modify the value of the local data
debugging a standalone Stateflow chart in MATLAB.
Do not use the keyword
thisto access chart data after simulation has stopped.
Calling an external function named
thisfrom a chart disables the keyword
thisthroughout the chart. To use the keyword, rename the extrinsic function.
Introduced in R2020b