Main Content

timescope

Display time-domain signals

Description

The timescope object displays signals in the time domain.

The scope window shown with data cursors.

Scope features:

  • Data Cursors — Measure signal values using vertical and horizontal cursors.

  • Signal Statistics — Display the maximum, minimum, peak-to-peak difference, mean, median, and RMS values of a selected signal.

  • Peak Finder — Find maxima, showing the x-axis values at which they occur.

  • Bilevel Measurements — Measure transitions, overshoots, undershoots, and cycles.

  • Triggers — Set triggers to sync repeating signals and pause the display when events occur.

Use Object Functions to show, hide, and determine visibility of the scope window.

Creation

Description

example

scope = timescope returns a timescope object, scope. This object displays real- and complex-valued floating and fixed-point signals in the time domain.

scope = timescope(Name,Value) returns a timescope object with properties set to the specified value. Specify properties and their values in quotes, separated by commas. You can specify name-value pair arguments in any order.

Properties

expand all

Most properties can be changed from the timescope UI.

Frequently Used

Sampling rate of the input signal, in hertz, specified as a finite numeric scalar or vector of scalars.

The inverse of the sample rate determines the x-axis (time axis) spacing between points in the displayed signal. When the value of NumInputPorts is greater than 1 and the sample rate is scalar, the object uses the same sample rate for all inputs. To specify different sample rates for each input, use a vector.

You can only set this property when creating the object or after calling release.

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Sample Rate.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Source of the time span for frame-based input signals, specified as one of the following:

  • 'property' – The object derives the x-axis limits from the TimeDisplayOffset and TimeSpan properties.

  • 'auto' – The x-axis limits are derived from the TimeDisplayOffset property, SampleRate property, and the number of rows in each input signal (FrameSize in the equations below). The limits are calculated as:

    • Minimum time-axis limit = TimeDisplayOffset

    • Maximum time-axis limit = TimeDisplayOffset + max(1/SampleRate.*FrameSize)

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Time Span.

Data Types: char | string

Time span, in seconds, specified as a positive, numeric scalar value. The time-axis limits are calculated as:

  • Minimum time-axis limit = TimeDisplayOffset

  • Maximum time-axis limit = TimeDisplayOffset + TimeSpan

Dependencies

To enable this property, set TimeSpanSource to 'property'.

UI Use

On the Scope tab, click Settings. Under Data and Axes, edit Time Span.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify how the scope displays new data beyond the visible time span as either:

  • 'scroll' — In this mode, the scope scrolls old data to the left to make room for new data on the right of the scope display. This mode is beneficial for debugging and monitoring time-varying signals.

  • 'wrap' — In this mode, the scope adds data to the left of the plot after overrunning the right of the plot.

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Overrun Action.

Data Types: char | string

Type of plot, specified as either:

  • 'line' — Line graph, similar to the line or plot function.

  • 'stairs' — Stair-step graph, similar to the stairs function. Stair-step graphs are useful for drawing time history graphs of digitally sampled data.

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Plot Type.

Data Types: char | string

When this property is set to:

  • 'onceatstop' –– The limits are updated once at the end of the simulation (when release is called).

  • 'auto' –– The scope attempts to always keep the data in the display while minimizing the number of updates to the axes limits.

  • 'manual' –– The scope takes no action unless specified by the user.

  • 'updates' –– The scope scales the axes once and only once after 100 updates to the visualization.

You can set this property only when creating the object.

Data Types: char | string

Advanced

Specify the layout grid dimensions as a two-element vector: [numberOfRows,numberOfColumns]. The grid can have a maximum of 4 rows and 4 columns.

Example: scope.LayoutDimensions = [2,4]

UI Use

On the Scope tab, click Display Grid () and select a specific number of rows and columns from the grid.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the units used to describe the x-axis (time axis). You can select one of the following options:

  • 'seconds' — In this mode, the scope always displays the units on the x-axis as seconds. The scope shows the word Time(s) on the x-axis.

  • 'none' — In this mode, the scope does not display any units on the x-axis. The scope only shows the word Time on the x-axis.

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Time Units.

Data Types: char | string

Specify, in seconds, how far to move the data on the x-axis. The signal value does not change, only the limits displayed on the x-axis change.

If you specify this property as a scalar, then that value is the time display offset for all channels. If you specify this property as a vector, each input channel can be a different time display offset

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Time Offset.

Time-axis labels, specified as:

  • 'all' — Time-axis labels appear in all displays.

  • 'bottom — Time-axis labels appear in the bottom display of each column.

  • 'none' — No labels appear in any display.

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Time Labels.

Data Types: char | string

Specify whether to display the scope in the maximized-axes mode. In this mode, the axes are expanded to fit into the entire display. To conserve space, labels do not appear in each display. Instead, the tick-marks and their values appear on top of the plotted data. You can select one of the following options:

  • 'auto' — The axes appear maximized in all displays only if the Title and YLabel properties are empty for every display. If you enter any value in any display for either of these properties, the axes are not maximized.

  • 'on' — The axes appear maximized in all displays. Any values entered into the Title and YLabel properties are hidden.

  • 'off' — None of the axes appear maximized.

UI Use

On the scope window, click on to maximize axes, hiding all labels and insetting the axes values.

Data Types: char | string

Specify the length of the buffer used for each input signal as a positive integer.

You can set this property only when creating the object.

UI Use

On the Scope tab, click Settings. Under Data and Axes, set Buffer Length.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Visualization

Specify the name of the scope as a character vector or string scalar. This name appears as the title of the scope's figure window. To specify a title of a scope plot, use the Title property.

Data Types: char | string

Scope window position in pixels, specified by the size and location of the scope window as a four-element vector of the form [left bottom width height]. You can place the scope window in a specific position on your screen by modifying the values of this property.

By default, the window appears in the center of your screen with a width of 800 pixels and height of 500 pixels. The exact values of the position depend on your screen resolution.

Specify the input channel names as a cell array of character vectors. The channel names appear in the legend, and on the Measurements tab under Select Channel. If you do not specify names, the channels are labeled as Channel 1, Channel 2, etc.

Dependency

To enable this property, set ShowLegend to true.

Data Types: char

Active display used to set properties, specified by the integer display number. The number of a display corresponds to the display's row-wise placement index. Setting this property controls which display is used for the following properties: YLimits, YLabel, ShowLegend, ShowGrid, Title, and PlotAsMagnitudePhase.

UI Use

On the Scope tab, click Settings. Under Display and Labels, set Active Display.

Specify the display title as a character vector or a string scalar.

Dependency

When you set this property, ActiveDisplay controls the display that is updated.

UI Use

On the Scope tab, click Settings. Under Display and Labels, set Title.

Data Types: char | string

Specify the text for the scope to display to the left of the y-axis.

Dependencies

This property applies only when PlotAsMagnitudePhase is false. When PlotAsMagnitudePhase is true, the two y-axis labels are read-only values "Magnitude" and "Phase", for the magnitude plot and the phase plot, respectively.

When you set this property, ActiveDisplay controls the display that is updated.

UI Use

On the Scope tab, click Settings. Under Display and Labels, set YLabel.

Data Types: char | string

Specify the y-axis limits as a two-element numeric vector, [ymin, ymax].

  • If PlotAsMagnitudePhase is false, the default is [-10,10].

  • If PlotAsMagnitudePhase is true, the default is [0,10]. This property specifies the y-axis limits of only the magnitude plot. The y-axis limits of the phase plot are always [-180,180]

Dependency

When you set this property, ActiveDisplay controls the display that is updated.

UI Use

On the Scope tab, click Settings. Under Display and Labels, set Y-Axis Limits.

To show a legend with the input names, set this property to true.

From the legend, you can control which signals are visible. In the scope legend, click a signal name to hide the signal in the scope. To show the signal, click the signal name again.

UI Use

On the Scope tab, click Settings. Under Display and Labels, select Show Legend.

Data Types: logical

Set this property to true to show grid lines on the plot.

UI Use

On the Scope tab, click Settings. Under Display and Labels, select Show Grid.

Plot signal as magnitude and phased, specified as either:

  • true – The scope plots the magnitude and phase of the input signal on two separate axes within the same active display.

  • false – The scope plots the real and imaginary parts of the input signal on two separate axes within the same active display.

This property is useful for complex-valued input signals. Turning on this property affects the phase for real-valued input signals. When the amplitude of the input signal is nonnegative, the phase is 0 degrees. When the amplitude of the input signal is negative, the phase is 180 degrees.

UI Use

On the Scope tab, click Settings. Under Display and Labels, select Magnitude Phase Plot.

Object Functions

To use an object function, specify the object as the first input argument.

hideHide scope window
showDisplay scope window
isVisibleDetermine visibility of scope
generateScriptGenerate MATLAB script to create scope with current settings
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a time-domain sinusoidal signal. Display the signal by calling the time scope object.

Create a sinusoidal signal with two tones, one at 0.3 kHz and the other at 3 kHz.

t = (0:1000)'/8e3;
xin = sin(2*pi*0.3e3*t)+sin(2*pi*3e3*t);

Create a timescope object and view the sinusoidal signal by calling the time scope object scope.

scope = timescope('SampleRate', 8e3,...
    'TimeSpanSource', 'property', ...
    'TimeSpan', 0.1);
scope(xin)

Run release to allow changes to property values and input characteristics. The scope automatically scales the axes.

release(scope);

Hide the scope window.

if(isVisible(scope))
    hide(scope)
end

Show the scope window.

if(~isVisible(scope))
    show(scope)
end

Introduced in R2020a