Main Content

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: Sine Wave, Pulse, Sawtooth and 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.

  1. Click Run to start a simulation.

  2. When the simulation has finished, click Data Inspector to open the Simulation Data Inspector.

  3. Plot the Output signal in the upper subplot.

  4. Plot the Sawtooth and Sine Wave signals 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 0 to 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 plot.

Visualization settings user interface for a time plot

With the Time span set to 150, click Run to start the simulation. When the simulation starts, the span from 0 to 150 is visible on the t-axis. After reaching 150, the t-axis shifts to show 150 to 300.

The output signal when the time span is set to 150 and the update mode is set to Wrap.

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 Wrap or Scroll. By default, the display updates by wrapping the plot.

In 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 150, t-axis scrolls with the streaming signal data.

The output signal when the time span is 150 and the update mode is set to scroll.

Freeze Display

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.

  1. To improve signal visibility, set Time span to 50.

  2. Start the simulation.

  3. Click Freeze display to prevent wrapping or scrolling. You can also zoom in on previous data to freeze the display.

  4. Click Show/hide data cursors . Then, select Two Cursors.

  5. Drag the cursors to measure the difference between two peaks in the Output or Sine Wave signal.

Using cursors to find the period of the sine wave while the display is frozen and the simulation is running.

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.

Note

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 1.

  • 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 0.

Note

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 Sine Wave and Sawtooth such that both signals are displayed between y values of 0 and 1.

  1. Select the signal Sawtooth. Then, in the Properties pane, set Display Scaling to 5 and Display Offset to 0.5.

    Properties pane showing the changes made to Display Scaling and Display Offset for the signal Sawtooth.

  2. Select the signal Sine Wave. Then, in the Properties pane, set Display Scaling to 0.5 and Display Offset to 0.5.

    Properties pane showing the changes made to Display Scaling and Display Offset for the signal Sine Wave.

  3. Select Fit to View in Y to adjust the view.

The Display Scaling and Display Offset have been changed for the signals Sawtooth and Sine Wave so that all values are between 0 and 1. Cursors are used to show that the values of the signals remain unchanged when the display is scaled or offset

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.

Related Topics