View Streaming Data in the Simulation Data Inspector
When streaming data to the Simulation Data Inspector, you can control how incoming data is displayed by specifying the behavior of the time axis. You can set a time span, choose how plot updates are drawn, and freeze the display to better view and analyze your streaming data. These options are helpful when working with real-time models or infinite simulation times or when you use simulation pacing to interact with the system. You can also use triggers to control when to draw the plot of a streaming signal in the Simulation Data Inspector. For more information, see Control Display of Streaming Data Using Triggers.
This example shows you how to control the time axis, display scaling, and display offset to better visualize your streaming data.
Open and Simulate the Model
This model generates four logged signals:
Output. The Switch block is configured to allow the sine signal to pass through when the output of the Pulse Generator block is greater than zero. When the output of the Pulse Generator block is less than or equal to zero, the Switch block allows the sawtooth signal to pass through.
The model uses simulation pacing to slow down the simulation, which allows you to interact with the system. For more information, see Simulation Pacing.
Click Run to start a simulation.
When the simulation has finished, click Data Inspector to open the Simulation Data Inspector.
Outputsignal in the upper subplot.
Sine Wavesignals in the lower subplot.
By default, the Simulation Data Inspector groups signals by domain. The
Signals grouping contains the output of the Pulse Generator block, the Signal Generator block, and the Sine Wave block. The
Outports grouping contains the logged model output from the Switch block. When you plot a signal after the simulation completes, the Simulation Data Inspector fits the view to display all the signal data.
Change Time Span
If the simulation time is finite, the Time span can be set to
auto. When Time span is set to
auto, the t-axis spans the full simulation time.
However, when you view the entire simulation at once, the characteristics of the sine wave
and sawtooth signals are hard to see. You can view a portion of the signal by setting the
Time span. Before beginning the simulation, you can change the size
of the visible time interval by changing the Time span value. Click
Visualization Settings . Then, in Limits > Time span, enter a value.
For example, set Time span to
150. Because the
plots are linked, the t-axis has limits
150 at the start of the simulation for both subplots. When
Link plot is selected, any changes made in Visualization Settings
apply to all linked subplots. Subplots are linked by default. To unlink a subplot, select
the subplot. Then, in the Visualization Settings, clear Link
With the Time span set to
Run to start the simulation. When the simulation starts, the span
150 is visible on the
t-axis. After reaching
t-axis shifts to show
Control Plot Update Behavior
You can change the way the Simulation Data Inspector updates subplots while streaming a
signal. Click Visualization Settings . Then, set Axes > Update mode to
default, the display updates by wrapping the plot.
Wrap mode, the Simulation Data Inspector shows streaming data
until it reaches the maximum t-axis limit. When the data reaches this
limit, the minimum and maximum t-axis limits are increased by the
Time span value.
Next, set Update mode to
Scroll. Start a
new simulation. In scroll mode, old data is moved out of view on the left as new data is
plotted on the right. In this mode, instead of jumping by
t-axis scrolls with the streaming signal data.
You can inspect your signal while the simulation is running by freezing the display. Suppose you want to measure the period of the sine wave while data is streaming. You can freeze the display and use cursors to find the difference between two peaks.
To improve signal visibility, set Time span to
Start the simulation.
Click Freeze display to prevent wrapping or scrolling. You can also zoom in on previous data to freeze the display.
Click Show/hide data cursors . Then, select Two Cursors.
Drag the cursors to measure the difference between two peaks in the
When you finish measuring, click Unfreeze display to return your view to the current simulation time. If the simulation ends while the display is frozen, the display jumps to the end.
The simulation continues to run when the display is frozen. To pause the simulation, click Pause in the model.
Control Display Scaling and Display Offset
You can vertically scale and shift the display of individual signals from the Properties pane of the Simulation Data Inspector.
Use the Display Scaling property to vertically scale the appearance of a plotted signal. The Simulation Data Inspector plots the signal values multiplied by the scaling value. By default, Display Scaling is
Use the Display Offset property to vertically shift the appearance of a plotted signal. The Simulation Data Inspector plots the summation of the offset value added to the signal values. By default, Display Offset is
Changing the value of Display Scaling or Display Offset affects how the Simulation Data Inspector displays a signal. Signal values are unchanged.
For example, you can change the scaling and offset values for
Sawtooth such that both signals are displayed
between y values of
Select the signal
Sawtooth. Then, in the Properties pane, set Display Scaling to
5and Display Offset to
Select the signal
Sine Wave. Then, in the Properties pane, set Display Scaling to
0.5and Display Offset to
Select Fit to View in Y to adjust the view.
Notice that the cursors display the original signal values. When you set Display Scaling or Display Offset to values other than the defaults, you change the appearance of the plot. However, cursors display the data value of the signal, which remains unchanged.