Display signals generated during simulation
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 (graphs) — 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 Signal 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.
Use scope parameters to change axis (graph) settings, data logging options, and figure color and style.
On the Scope window toolbar, click the Parameters button
Edit the scope parameters.
Click the Apply or OK button. The values you entered or selected apply to the next simulation.
Set the axis parameters, time range, tick labels, and decimation or sample time.
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.
Range of x-axis in Scope window. Do not enter a variable name in this field. Enter either,
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
Specify how to display labels on the tick marks. The options are:
all — Place tick labels on the outside of the x-axes and y-axes
inside — Place tick labels inside all axes (available only on scope viewers)
bottom-axis only — Place tick labels only on the x-axes
none — Do not label ticks
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.
Changes a Scope block into a Floating Scope block.
Displays a legend of signal names with color and style.
Use this pane to control the amount of data a Scope collects during a simulation and where to save the data.
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.
Select this option to save collected 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.
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.
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.
Select the background color for the Scope window.
Select the background color for axes (graphs) with the first color pallet. Select the grid and label color with the second pallet.
For graphs with more than one line, select a line number.
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.
Select the marker style.
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.
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.
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.
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.
Set y-axis limits by right-clicking an axis (graph) and selecting Axes Properties. The following dialog box opens.
Enter the minimum value for the y-axis.
Enter the maximum value for the y-axis.
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).
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.
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.
On the Scope window toolbar, click the Parameters button, and then select the History tab.
Select the Save data to workspace check box, and in the Variable name field, enter a valid MATLAB variable name. For example, enter
From the Format list, select Structure with time. Click OK or Apply.
Run a simulation.
In the MATLAB Command Window, type:
A Figure window opens with a plot of the scope data.
Edit the plot. See "Plots and Plotting Tools" in the MATLAB documentation.