|On this page…|
During simulation you can hover over objects in the chart to view the value of data used by the selected object. You can watch data whether simulation runs or pauses. Hovering over objects in the chart provides the following information:
|States and transitions||Values of data used by the object|
|Graphical, truth table, and MATLAB functions||Values of local data, and of inputs and outputs in the scope of the function|
For example, the following chart stops execution before entering the Debounce state. Hovering over the transition from the Normal state to the On state shows that the value of sw is 3.6333.
Because the value of sw is greater than zero, the chart takes the transition from Normal to enter the Debounce state.
To see a list of all data values in scope, use the Browse Data pull-down menu in the Stateflow® debugger. You can display selected data in the bottom output display pane of the debugger during simulation, after a breakpoint is reached. The debugger can filter the display between:
Watched data and all data
Watched data in the currently executing chart and watched data for all charts in a model
The following example displays All Data (All Charts) for a chart named Air Controller. This chart has two data values: airflow and temp.
Each displayed object (chart, state, data, and so on) appears with a unique identifier of the form (#id(xx:yy:zz)), which links the listed object to its appearance in the chart. In the Browse Data section, data appears in alphabetical order, regardless of its scope in a chart.
Note: Fixed-point data appears with two values: the quantized integer value (stored integer) and the scaled real-world (actual) value. For more information, see How Fixed-Point Data Works in Stateflow Charts.
When simulation reaches a breakpoint, you can view the values of Stateflow data in the MATLAB® Command Window. In the following chart, a default transition calls a MATLAB function:
A breakpoint is set at the last executable line of the function:
function stats(vals) %#codegen % calculates a statistical mean and standard deviation % for the values in vals. len = length(vals); mean = avg(vals, len); stdev = sqrt(sum(((vals-avg(vals,len)).^2))/len); coder.extrinsic('plot'); plot(vals,'-+'); % Breakpoint set at this line
When simulation reaches the breakpoint, you can display Stateflow data in the MATLAB Command Window.
A debug>> prompt appears.
Advance to next executable line of code.
|When debugging MATLAB functions in a chart:|
Continue execution to next breakpoint.
Stop simulation of the model. Press Enter after this command to return to the command prompt.
Display help for command-line debugging.
Display the value of the variable var.
|var (i)||Display the value of the ith element of the vector or matrix var.|
|var (i:j)||Display the value of a submatrix of the vector or matrix var.|
Display the size and class (type) of all variables in the scope of the halted MATLAB function in your chart.
You can issue any other MATLAB command at the debug>> prompt but the results are executed in the Stateflow workspace. For example, you can issue the MATLAB command plot(var) to plot the values of the variable var.
To issue a command in the MATLAB base workspace at the debug>> prompt, use the evalin command with the first argument 'base' followed by the second argument command string, for example, evalin('base','whos').