During simulation, if you point at an object in the chart, a tooltip displays the value of the data and the messages that the selected object uses.
|Object Type||Tooltip Information|
|States and transitions||Values of data, messages, and temporal logic expressions that the object uses|
|Graphical, truth table, and MATLAB functions||Values of local data, messages, inputs, and outputs in the scope of the function|
If you select the chart properties Export Chart Level Functions and Treat Exported Functions as Globally Visible, then the tooltip does not display temporal logic data.
For example, this chart stops execution before entering the
state. Pointing to the superstate
gear displays a tooltip showing the
Data such as
Temporal logic expressions such as
Because the value of
duration(speed >= up_threshold) is
TWAIT, the chart takes the transition from
A chart determines the value of data and temporal logic expressions at different stages
of a time step. For instance, in the previous example, the chart computes temporal
information at the start of each time step and updates
speed at the end
of each time step. If you advance through the simulation using the Step
option and observe data at the end of each time step, the
temporal information in the tooltip can appear to lag behind the rest of the data. After
observing the value of
speed cross the
you must step forward twice before
duration(speed >= up_threshold)
becomes nonzero. To avoid this behavior, use the Step Over
option and observe the data at shorter intervals.
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.
At the MATLAB prompt, press Enter.
debug>> prompt appears.
whos to view the data that is visible
at the current scope.
Enter the name of data array
vals at the
prompt to display its value.
vals(2:3) to view specific values of
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
|Display the value of the |
|Display the value of a submatrix of the vector or matrix
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
var) to plot the
values of the variable
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, for example,
To return to the MATLAB base workspace, use the
In the Watch tab of the Stateflow Breakpoints and Watch window, you can view current data and messages when simulation pauses. The Watch tab displays a list of watch data, and highlights the values that changed since the last time simulation paused. In the Watch tab, you can expand a message to view the message queue and message data values. To add Stateflow data or messages to the watch data list:
In the chart, right-click an object that uses the data or message.
Select Add to Watch Window.
Choose the data or message.
To add active state data and truth table data to the watch list, from the Model Explorer, open the Data Properties dialog box. Select Add to Watch Window.
You can choose the display format for each data type. For more information, see Format Watch Display.