Scope and Floating Scope

Display signals generated during simulation

Library

Sinks

Description

The Scope block displays inputs signals with respect to simulation time.

  • Scope window — If a Scope window is closed at the start of a simulation, scope data is still written to the connected Scope. As a result, if you open a Scope after a simulation, the Scope window displays the input signal or signals.

  • Plotting signals — If the input signal is continuous, the Scope draws a point-to-point plot. If the signal is discrete, the Scope draws a stair-step plot.

  • Time step values — The Scope block only displays major time step values. The scope displays additional interpolated points between major time steps if specified by the refine parameter.

  • Multiple y-axes (plots) — A Scope window can display multiple y-axes (graphs) with one graph per input port. All of the y-axes have a common time range on the x-axis. The Scope block allows you to adjust the amount of time and the range of input values displayed. You can modify the Scope parameter values during a simulation.

  • Data type support — The Scope block accepts real (not complex) signals of any data type that Simulink® supports, including fixed-point and enumerated data types. The Scope block also accepts homogeneous vectors. For more information, see Data Types Supported by Simulink in the Simulink documentation.

    Note:   A Scope block is not the same as a Scope Viewer. For information about Scope Viewers, see Scope Viewer Tasks

    Note:   If you want to display internal data from a library block that you create, do not use a Scope block inside the library block. Instead, provide your library block with output ports, and then connect the ports to a Scope block external to the library block.

Scope Parameters

Use scope parameters to change axis (graph) settings, data logging options, and figure color and style.

    Note:   Changing Scope dialog parameters using set_param may put the Scope in an undefined state.

  1. On the Scope window toolbar, click the Parameters button

  2. Edit the scope parameters.

  3. Click the Apply or OK button. The values you entered or selected apply to the next simulation.

General Pane

Set the axis parameters, time range, tick labels, and decimation or sample time.

Number of axes

Number of y-axes (graphs) and input ports on the Scope block. With the exception of the Floating Scope, there is no limit to the number of y-axes a Scope window can contain. All axes share the same time base (x-axis), but have independent y-axes.

Time range

Range of x-axis in Scope window.

  • A number — Each screen displays an amount of time data corresponding to the length of the range

  • auto — Sets the x-axis to the duration of the simulation

Tick labels

Specify how to display labels on the tick marks. The options are:

  • all — Places tick labels on the outside of x-axes and y-axes

  • none — Removes tick labels from all axes, including the left side x-axes

  • bottom-axis only — For multi-axis viewers, places tick labels on the bottom y-axis

Scroll

When you select this option, the scope continuously scrolls the displayed signals to the left to keep as much data in view as will fit on the screen at any one time. The signal trace moves to the left as new data is added to the right.

In contrast, when this option is not selected, the scope draws a screen full of data from left to right until the screen is full, erases the screen, and then restarts drawing data from left to right. This loop is repeated until the end of simulation time. The effects of this option are discernible only when drawing is slow, for example, when the model is very large or has a very small step size.

Legends

Add a signal legend to a scope window. The names listed in the legend are the signal names from the model. For signals with multiple channels, a channel index is appended after the signal name.

For example, connect a Sine Wave block to a Scope. Set the Amplitude parameter for the Sine Wave to [1 2]. Select the Legends check box for the Scope. Set the Signal name property for the signal to MySignal.

After simulating this model, the Scope window displays a sine wave for the two signal channels in MySignal, MySignal:1 and MySignal:2.

See also: Signal Dimensionsand Determine Output Signal Dimensions.

Continuous signals have straight lines before their names while discrete signals have step-shaped lines.

Floating scope

Changes a Scope block into a Floating Scope block.

Sampling

Specify the number of data points to plot. Select either,

  • Decimation — Plot signal data for every Nth time step. Entering 1 plots every time step.

  • Sample time — Plot signal data for each time step at a specified time interval. This parameter is useful when you are using a variable-step solver where the interval between time steps might not be the same.

After you make a selection, enter a number in the data field.

History Pane

History pane with the Floating Scope check box on the General pane cleared.

History pane with the Floating Scope check box on the General pane selected.

Use this pane to control the amount of data a Scope collects during a simulation and where to save the data.

Limit data points to last

Specify the number of data points a Scope collects. If you select this option, enter a value in the data field. The Scope relies on its data history for zooming and auto-scaling operations. If the number of data points is limited to 1,000 and the simulation generates 2,000 data points, only the last 1,000 are available for regenerating the display.

    Note:   If you do not select the Limit data points to last check box, the memory consumed by MATLAB steadily increases as the simulation stores the entire simulation history. The result may be an out of memory error.

    For simulations with a small time step, check the memory in your system. If the available memory is limited, select Decimation from the Sampling drop down list and enter a value greater than 1. This reduces the number of points a simulation stores.

    For simulations with the Stop time set to inf, always select the Limit data points to last check box and enter a value.

Save data to workspace

Select this option to save data to the MATLAB® workspace. If you select this option, the Variable name and Format fields become active. Simulink logs fixed-point data as double.

Log/Unlog Viewed Signals to Workspace

If you select the Floating Scope check box on the General pane, Save data to workspace is disabled and replaced by a Log/Unlog Viewed Signals to Workspace button. Clicking this button sets the Log signal data property check boxes for the signals you selected with the Signal Selector. Clicking this button a second time, clears the Log signal data property check boxes.

Running a simulation saves the signal data to a Dataset object. Enter the name of the object in Model Configuration Parameters dialog > Data Import/Export pane > Signal logging text box.

Variable name

Enter a valid MATLAB variable name. The name must be unique among all data logging variables in your model. Other data logging variables include those defined on other Scope blocks, To Workspace blocks, and simulation return variables such as time, states, and outputs.

Format

Select one of three formats to save data:

  • Array — Use for a Scope with one set of axes.

  • Structure — Use for Scopes with more than one set of axes and when you do not want to save time data.

  • Structure with time — Use when you want to save time data.

Style Pane

Figure color

Select the background color for the Scope window.

Axes colors

Select the background color for axes (graphs) with the first color pallet. Select the grid and label color with the second pallet.

Properties for line

For graphs with more than one line, select a line number.

Line

Select line style, width, and color.

The Scope block displays one input per axes. When displaying a vector or matrix of signals on the same axis, the Scope block assigns colors to each signal, in this order: yellow, magenta, cyan, red, green, and dark blue. If there are more than six signals, the Scope block recycles through the colors a second time.

Marker

Select the marker style.

Scope Zooming

To zoom in on data in both the x and y directions, select the left most Zoom toolbar button, and then define the zoom region with a bounded box. When you release the mouse button, the Scope displays the data in that area. You can also click a point in the area you want to zoom in on.

This figure shows a zoomed region before you release the mouse button.

To zoom in on data in just the x direction, click the middle Zoom toolbar button. Define the zoom region by positioning the pointer at one end of the region, pressing and holding down the mouse button, then moving the pointer to the other end of the region. This figure shows the Scope after you define the zoom region, but before you release the mouse button.

When you release the mouse button, the Scope displays the magnified region.

Zooming in the y direction works in the same way, except that you click the right most Zoom toolbar button before defining the zoom region.

    Note   Since Floating Scope does not buffer the data it displays, you cannot zoom the contents. Simulink disables (grays) the Zoom button on the toolbar of a Floating Scope. For the same reason, stepping back a simulation is also not supported.

Autoscaling the Scope Axes

User the Autoscale button to view the minimum and maximum points of your signals.

If you click the Autoscale button while a simulation is running, the axes are autoscaled based on the data that appears on the current screen, and the autoscale limits are saved as the defaults. Then next simulation you run also uses the new axes limits.

    Note:   Since the Floating Scope does not buffer the data it displays, you cannot autoscale the contents. Simulink disables the Autoscale button on the toolbar of a Floating Scope.

Saving and Restoring the Axes Settings

Use the Save current axes setting toolbar button to store the current x-axis and y-axis settings.

If you select the Save current axes settings button, the block specifies its current y-limits as the values of the Y-min and Y-max parameters (see Y-Axis Limits. Similarly, the block specifies its current x-axis limits as the value of the Time range parameter (see General Pane).

Use the Restore saved axes settings button to restore the saved axis settings.

Floating Scope

You can change a Scope block to a Floating Scope block from the toobar.

To add signals to a Floating Scope, click the Signal Selector button , and then select signals from your model. For more information, see Signal Selector.

    Tip   Before using a Floating Scope in a simulation, clear the Signal storage reuse check box in the Optimization > Signals and Parameters pane of the Configuration Parameters dialog box. For more information, see Optimization Pane: Signals and Parameters.

Y-Axis Limits

Set y-axis limits by right-clicking an axis (graph) and selecting Axes Properties. The following dialog box opens.

Y-min

Enter the minimum value for the y-axis.

Y-max

Enter the maximum value for the y-axis.

Title

Enter the title of the plot. You can include a signal label in the title by typing %<SignalLabel> as part of the title string (%<SignalLabel> is replaced by the signal label).

    Note:   You cannot add a title to a Floating Scope window.

Plotting Data During Simulation

To improve run-time performance during long simulations, Simulink reduces the signal data before plotting in a scope window. After the simulation is complete and if you cleared the Limit data points to last check box, Simulink replots the full set of cached data.

Time Offset

This figure shows the Scope block displaying the output of the vdp model. The simulation runs for 40 seconds. This scope shows the final 20 seconds of the simulation. The Time offset field displays the time corresponding to 0 on the horizontal axis. Therefore, you have to add the offset to the fixed time range values on the x-axis to get the actual time.

Creating a MATLAB Figure from Scope Block Data

If you need more drawing tools than provided with the Scope window, you can save scope data to the MATLAB workspace, replot the scope data in a Figure window, and then use the Plotting Tools.

  1. On the Scope window toolbar, click the Parameters button, and then select the History tab.

  2. Select the Save data to workspace check box, and in the Variable name field, enter a valid MATLAB variable name. For example, enter

    ScopeData
  3. From the Format list, select Structure with time. Click OK or Apply.

  4. Run a simulation.

  5. In the MATLAB Command Window, type:

    plot(ScopeData.time,ScopeData.signals.values)

    A Figure window opens with a plot of the scope data.

  6. Edit the plot. See "Plots and Plotting Tools" in the MATLAB documentation.

Characteristics

Sample Time

Inherited from driving block or you can set

States

0

Multidimensionalized

Yes

Was this topic helpful?