| Contents | Index |
| On this page… |
|---|
About Test Points in Stateflow Charts Setting Test Points for Stateflow States and Local Data with the Model Explorer Using a Floating Scope to Monitor Data Values and State Activity |
A Stateflow test point is a signal that you can observe during simulation — for example, by using a Floating Scope block. You can designate the following Stateflow objects as test points:
Any state
Local data with the following characteristics:
Can be scalar, one-dimensional, or two-dimensional in size
Can be any data type except ml
Must be a descendant of a Stateflow chart
You can specify individual data or states as test points by setting their TestPoint property via the Stateflow API or in the Model Explorer (see Setting Test Points for Stateflow States and Local Data with the Model Explorer).
You can monitor individual Stateflow test points with a floating scope during model simulation. You can also log test point values into MATLAB workspace objects.
You can explicitly set individual states or local data as test points in the Model Explorer. The following procedure shows how to set individual test points for Stateflow states and data.

The model consists of a Sine Wave block that triggers a Stateflow chart using the input trigger event tic.
Add the following states and transitions to your chart:

The state A and its substate X are entered on the first tic event. State A and substate X stay active until 10 tic events have occurred, and then state B is entered. On the next event, state A and substate X are entered and the cycle continues.
The data x belongs to substate X. The entry and during actions for substate X increment x while X is active for 10 tic events. When state B is entered, x reinitializes to zero, and then the cycle repeats.
Open the Configuration Parameters dialog box.
In the Solver pane, specify solver options:
Set Type to Fixed-step.
Set Solver to discrete (no continuous states).
Set Fixed-step size (fundamental sample time) to 0.1.
Click OK.
In the Model Explorer, expand the myModel node and then the Chart1 node.
In the properties dialog box, select the Test point check box and then click OK.
This step creates a test point for the state A.
Right-click the local data x and select Properties.
In the properties dialog box, select the Test point check box and then click OK.
You can also log these test points. See Logging Multiple Signals At Once for instructions on using the Signal Logging dialog box. See Logging Chart Signals Using the Command-Line API for instructions on logging signals at the MATLAB command line.
In this section, you configure a Floating Scope block to monitor a data value and the activity of a state.
Create this model:

The model consists of a Floating Scope block and a Stateflow chart.
Add the following states and transitions to your chart:

The chart starts by adding an increment of 0.02 for 10 samples to the data x1. For the next 10 samples, x1 increments by 0.2, and then the cycle repeats.
Save the model.
Open the Configuration Parameters dialog box.
In the Solver pane, specify solver options:
Set Type to Fixed-step.
Set Solver to discrete (no continuous states).
Set Fixed-step size (fundamental sample time) to 0.1.
Click OK.
Specify states A and B as test points:
In the chart, right-click each state and select Properties.
In the State properties dialog box, select Test point.
Click OK.
Specify data x1 as a test point:
Open the Model Explorer.
In the Model Hierarchy pane, navigate to the chart.
In the Contents pane, right-click x1 and select Properties.
In the Data properties dialog box, select Test point.
Click OK.
Close the Model Explorer.
In the
Floating Scope window, click the Signal Selection icon
.
The Signal Selector dialog box appears with a hierarchy of Simulink blocks for the model.
In the Model hierarchy pane, select the chart whose signals you want to monitor and in the List contents pane, select the signals.

You see a signal trace for x1 and the activity of state A.

When state A is active, the signal value is 1. When that state is inactive, the signal value is 0. Because this value can be very low or high compared to other data, you might want to add a second Floating Scope block to compare the activity signal with other data.
![]() | Changing Data Values During Simulation | Logging Data Values and State Activity | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |