Display time-domain signals
The timescope
object displays signals in the time
domain.
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.
returns a
scope
= timescopetimescope
object, scope
. This object displays
real- and complex-valued floating and fixed-point signals in the time domain.
returns a scope
= timescope(Name,Value
)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.
Most properties can be changed from the timescope
UI.
SampleRate
— Sample rate of inputs1
(default) | finite numeric scalar | vectorSampling 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
.
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
TimeSpanSource
— Source of time span'auto'
(default) | 'property'
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)
On the Scope tab, click Settings. Under Data and Axes, set Time Span.
Data Types: char
| string
TimeSpan
— Time span10
(default) | positive scalarTime 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
To enable this property, set TimeSpanSource
to
'property'
.
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
TimeSpanOverrunAction
— Data overrun behavior'scroll'
(default) | 'wrap'
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.
On the Scope tab, click Settings. Under Data and Axes, set Overrun Action.
Data Types: char
| string
PlotType
— Type of plot'line'
(default) | 'stairs'
Type of plot, specified as either:
On the Scope tab, click Settings. Under Data and Axes, set Plot Type.
Data Types: char
| string
AxesScaling
— Axes scaling mode'onceatstop'
(default) | 'auto'
| 'manual'
| 'updates'
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
LayoutDimensions
— Display layout grid dimensions[1,1]
(default) | [numberOfRows, numberOfColumns]
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]
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
TimeUnits
— Units of x-axis'seconds'
(default) | 'none'
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.
On the Scope tab, click Settings. Under Data and Axes, set Time Units.
Data Types: char
| string
TimeDisplayOffset
— Offset x-axis limitsSpecify, 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
On the Scope tab, click Settings. Under Data and Axes, set Time Offset.
TimeAxisLabels
— Time-axis labels'all'
(default) | 'bottom
| 'none'
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.
On the Scope tab, click Settings. Under Data and Axes, set Time Labels.
Data Types: char
| string
MaximizeAxes
— Maximize axes control'auto'
(default) | 'on'
| 'off'
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.
On the scope window, click on to maximize axes, hiding all labels and insetting
the axes values.
Data Types: char
| string
BufferLength
— Buffer length50000
(default) | positive integerSpecify the length of the buffer used for each input signal as a positive integer.
You can set this property only when creating the object.
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
Name
— Window name'Time Scope'
(default) | character vector | string scalarSpecify 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
Position
— Window position[left bottom width height]
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.
ChannelNames
— Channel names{''}
(default) | cell array of character vectorsSpecify 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.
To enable this property, set ShowLegend
to
true
.
Data Types: char
ActiveDisplay
— Active display for setting properties1
(default) | integerActive 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
.
On the Scope tab, click Settings. Under Display and Labels, set Active Display.
Title
— Display title''
(default) | character vector | string scalarSpecify the display title as a character vector or a string scalar.
When you set this property, ActiveDisplay
controls the
display that is updated.
On the Scope tab, click Settings. Under Display and Labels, set Title.
Data Types: char
| string
YLabel
— y-axis label'Amplitude'
(default) | character vector | string scalarSpecify the text for the scope to display to the left of the y-axis.
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.
On the Scope tab, click Settings. Under Display and Labels, set YLabel.
Data Types: char
| string
YLimits
— y-axis limits[-10,10]
(default) | [ymin, ymax]
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]
When you set this property, ActiveDisplay
controls the
display that is updated.
On the Scope tab, click Settings. Under Display and Labels, set Y-Axis Limits.
ShowLegend
— Show legendfalse
(default) | true
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.
On the Scope tab, click Settings. Under Display and Labels, select Show Legend.
Data Types: logical
ShowGrid
— Grid visibilitytrue
(default) | false
Set this property to true
to show grid lines on the
plot.
On the Scope tab, click Settings. Under Display and Labels, select Show Grid.
PlotAsMagnitudePhase
— Plot signal as magnitude and phasefalse
(default) | true
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.
On the Scope tab, click Settings. Under Display and Labels, select Magnitude Phase Plot.
To use an object function, specify the object as the first input argument.
hide | Hide scope window |
show | Display scope window |
isVisible | Determine visibility of scope |
generateScript | Generate MATLAB script to create scope with current settings |
step | Run System object algorithm |
release | Release resources and allow changes to System object property values and input characteristics |
reset | Reset internal states of System object |
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
You have a modified version of this example. Do you want to open this example with your edits?