| Stateflow® | ![]() |
| On this page… |
|---|
The Browse Data pull-down menu in the Stateflow® Debugger lets you display selected data in the bottom output display pane of the Stateflow 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
Note You designate Stateflow data to be watched data by enabling the property Watch in Stateflow® Debugger, as described in Properties You Can Set in the Value Attributes Pane. |
The following example displays All Data (All Charts) for two executing charts, Chart1 and Chart2, in a simulating model. Each chart has its own data value: x1 and x2, respectively.

The data for each chart is headed by its owning object. Each displayed object (chart, state, data, and so on) is accompanied by a unique identifier in the form (#id(xx:yy:zz)), which is used in linking the listed object to its appearance in the Stateflow 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 Using Fixed-Point Data in Stateflow® Charts. |
When simulation reaches a breakpoint, you can view the values of Stateflow data in the MATLAB® Command Window. In the following example, a default transition calls an Embedded MATLAB™ function with a breakpoint set at the last executable line of the function:

When simulation reaches the breakpoint, you can display Stateflow data in the MATLAB Command Window. Assuming you want to watch the data variable vals from the previous example, follow these steps:
At the MATLAB prompt, press Enter.
A debug>> prompt appears.
Enter the MATLAB command whos to view the data that is visible at the current scope.
debug>> whos
Name Size Bytes Class
vals 4x1 32 double array
len 1x1 8 double array
stdev 1x1 8 double array
mean 1x1 8 double array
invals 4x1 32 double array
Grand total is 5 data in scope
debug>>
Enter the name of data array vals at the prompt to display its value.
debug>> vals
vals =
2
3
4
5
debug>>
Enter vals(2:3) to view the values of a submatrix of the array.
debug>> vals (2:3)
ans =
3
4
debug>>The Command Line Debugger provides these commands during simulation:
Command | Description |
|---|---|
dbstep | Advance to next executable line of code. |
dbstep [in/out] | When debugging Embedded MATLAB functions:
|
dbcont | Continue execution to next breakpoint. |
dbquit (ctrl-c) | Stop simulation of the model. Press Enter after this command to return to the command prompt. |
help | Display help for command-line debugging. |
print var ...or... var | 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. |
save | Saves all variables to the specified file. Follows the syntax of the MATLAB save command. To retrieve variables in the MATLAB base workspace, use the load command after simulation has ended. |
whos | Display the size and class (type) of all variables in the scope of the halted Embedded MATLAB function. |
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').
Note To return to the MATLAB base workspace, use the dbquit command. |
![]() | Debugging Cyclic Behavior | Monitoring Test Points in Stateflow® Charts | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |