Package: dsp
Display vectors or arrays
The ArrayPlot
object displays vectors or arrays.
To display vectors or array in Array Plot:
Define and set up your Array Plot. See Construction.
Call step
to display the vectors
or arrays in the Array Plot figure. The behavior of step
is
specific to each object in the toolbox.
Use the MATLAB® clear
function
to close the Array Plot figure window and clear its associated data.
Use the hide
method to hide the ArrayPlot window and
the show
method
to make it visible.
Use the MATLAB mcc
function
to compile code containing an Array Plot.
See the following sections for more information on the Array Plot Graphical User Interface:
Note:
Starting in R2016b, instead of using the |
H = dsp.ArrayPlot
creates
an Array Plot System object, H
. This object displays
vectors or arrays.
H = dsp.ArrayPlot('
creates
an Array Plot System object, Name
',Value
,...)H
, with each specified
property Name
set to the specified value.
You can specify Name
–Value
arguments
in any order.
|
Input channel names Specify as a cell array of character vectors the input channels
names to display in the legend, which is visible only when the Default: empty cell array |
|
X-data values Specify the desired x-data values as a row
or column vector of length equal to the frame length of the inputs.
This property is used only if the An example of a Name-Value pair to specify logarithmic x-data
scaling is Default: empty vector |
|
Maximize axes control Specify whether to display the scope in maximized axes mode. In this mode, each of the axes is expanded to fit into the entire display. To conserve space, labels do not appear in the display. Instead, tick-mark values appear on top of the plotted data. You can select one of the following options:
This property is Tunable. Default: |
|
Caption to display on Scope window Specify as a character vector the caption to display on the scope window. This property is Tunable. Default: |
|
Number of input signals Specify the number of input signals to display on the scope
as a positive integer. You must invoke the Default: |
|
Plot signal as Magnitude-and-Phase When you set this property to Default: |
|
Option to control the type of plot Specify the type of plot to use for all the input signals displayed in the scope window.
This property is Tunable. Default: |
|
Scope window position in pixels Specify, in pixels, the size and location of the scope window as a 4-element double 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 to this property. This property is Tunable. Default: The default depends on your screen resolution. By default,
the Scope window appears in the center of your screen with a width
of |
|
Reduce updates to improve performance When you set this property to You can also modify this property from the scope window. Opening
the Playback menu and clearing the Reduce
Updates to Improve Performance check box is the same
as setting this property to Default: |
|
Sample increment of input Specify the spacing between samples along the x-axis
as a finite numeric scalar. The input signal is only y-axis
data. x-axis data is set automatically based on
the Default: |
|
Option to enable or disable grid display When you set this property to Default: |
|
Source of legend When you set this property to Default: |
|
Display title Specify the display title as a character vector. Enter Default: |
|
Source of the x-data spacing Specify whether to use the Default: |
|
The label for the x-axis Specify the text for the scope to display below the x-axis. This property is Tunable. Default: |
|
x-axis display offset Specify the offset to apply to the x-axis. This property is a numeric scalar. This property is Tunable. Default: |
|
x-axis scale Specify Default: |
|
The label for the y-axis Specify the text for the scope to display to the left of the y-axis. Tunable Default: |
|
The limits for the y-axis Specify the y-axis limits as a 2-element
numeric vector, Default: |
clone | Create scope object with same property values |
getNumInputs | Number of expected inputs to step method |
getNumOutputs | Number of outputs of step method |
hide | Hide scope window |
isLocked | Locked status for input attributes and nontunable properties |
release | Allow property value and input characteristics changes |
reset | Reset internal states of scope object |
show | Make scope window visible |
step | Display signal in scope figure |
The following examples illustrate how to use the Array Plot object to view a variety of input signals.
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step
syntax. For example, myObject(x) becomes step(myObject,x).
View a Gaussian, or normal, distribution on the Array Plot figure.
Create a new Array Plot object.
h = dsp.ArrayPlot;
Configure the properties of the Array Plot object for a Gaussian distribution.
h.YLimits = [0 1]; h.XOffset = -2.5; h.SampleIncrement = 0.1; h.Title = 'Gaussian distribution'; h.XLabel = 'X'; h.YLabel = 'f(X)';
Call the
method to plot a Gaussian distribution.dsp.ArrayPlot.step
h(exp(-(-2.5:.1:2.5).*(-2.5:.1:2.5))');
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step
syntax. For example, myObject(x) becomes step(myObject,x).
View Least Mean Squares (LMS) adaptive filter weights on the Array Plot figure. Watch the filter weights change as they adapt to filter a noisy input signal.
Create an LMS adaptive filter System object.
hlms = dsp.LMSFilter(40,'Method', 'Normalized LMS', 'StepSize', .002);
Create and configure an audio file reader System object to read the input signal from the specified audio file.
hsigsource = dsp.AudioFileReader('dspafxf_8000.wav', ... 'SamplesPerFrame', 40, ... 'PlayCount', Inf,... 'OutputDataType', 'double');
Create and configure a fixed-point Finite Impulse Response (FIR) digital filter System object to filter random white noise, creating colored noise.
hfilt = dsp.FIRFilter('Numerator', fir1(39, .25));
Create and configure an Array Plot System object to display the adaptive filter weights.
harrayplot = dsp.ArrayPlot('XLabel', 'Filter Tap', ... 'YLabel', 'Filter Weight', ... 'YLimits', [-.05 .2]');
Plot the LMS filter weights as they adapt to a desired signal. Read from the audio file, produce random data, and filter the random data. Update the filter weights and plot the filter weights.
numplays = 0; while numplays < 3 [y, eof] = hsigsource(); noise = rand(40,1); noisefilt = hfilt(noise); desired = y + noisefilt; [~, ~, wts] = hlms(noise, desired); harrayplot(wts); numplays = numplays + eof; end
Array Plot uses the XOffset
and SampleIncrement
properties
to determine the time range. To change the X-offset setting
in the Array Plot figure, select View > Configuration Properties.
The Visuals — Array Plot Properties dialog box appears. Go
to the Main tab, and modify the value for the X-offset.
The span of the x-axis data is related to
the SampleIncrement
property by the equation .
Suppose you set SampleIncrement
to 0.1
and
the input signal data has 51 samples. The scope displays values on
the x-axis from 0
to 5
.
If you also set the X-offset to –2.5
,
the scope displays values on the x-axis from –2.5
to 2.5
.
The values on the x-axis of the scope display remain
the same throughout simulation.
The following figure highlights the important aspects of the Array Plot window.
Minimum x-axis limit — Array Plot sets the minimum x-axis limit using the value of the X-offset parameter on the Main tab of the Visuals—Array Plot Properties dialog box.
Maximum x-axis
limit — Array Plot sets the maximum x-axis
limit by summing the value of X-offset parameter
with the span of x-axis values. The equation defines
the relationship of the span of the x-axis data
to the SampleIncrement
property.
Simulation status — Provides the current status of the model simulation. The status can be either of the following conditions:
Processing
— Occurs after
you run the step
method and before
you run the release
method.
Stopped
— Occurs after
you construct the scope object and before you first run the step
method. This status also occurs after
you run the release
method.
The Simulation status is part of the Status Bar in the scope window. You can choose to hide or display the entire Status Bar. From the scope menu, select View > Status Bar.
By default, if the input signal has multiple channels, the scope
uses an index number to identify each channel of that signal. For
example, a 2-channel signal would have the following default names
in the channel legend: Channel 1
, Channel
2
. To show the legend, select View > Configuration Properties,
click the Display tab, and select the Show
Legend check box. If there are a total of 7 input channels,
the following legend appears in the display.
By default, the scope has a black axes background and chooses line colors for each channel in a manner similar to the Simulink® Scope block. When the scope axes background is black, it assigns each channel of each input signal a line color in the order shown in the above figure.
If there are more than 7 channels, then the scope repeats this
order to assign line colors to the remaining channels. To choose line
colors for each channel, change the axes background color to any color
except black. To change the axes background color to white, select View > Style, click the Axes background color button (
), and select
white from the color palette. Run the simulation again. The following
legend appears in the display. This is the color order when the background
is not black.
The Array Plot toolbar contains the following buttons.
Button | Menu Location | Shortcut Keys | Description |
---|---|---|---|
| File > Print | Ctrl+P | Print the current scope window. To print the current scope window to a figure rather than sending it to your printer, select File > Print to figure. |
Button | Menu Location | Shortcut Keys | Description |
---|---|---|---|
| Tools > Zoom In | N/A | When this tool is active, you can zoom in on the scope window. To do so, click in the center of your area of interest, or click and drag your cursor to draw a rectangular area of interest inside the scope window. |
| Tools > Zoom X | N/A | You access the Zoom X button from the menu under the Zoom In icon. When this tool is active, you can zoom in on the x-axis. To do so, click inside the scope window, or click and drag your cursor along the x-axis over your area of interest. |
| Tools > Zoom Y | N/A | You access the Zoom Y button from the menu under the Zoom In icon. When this tool is active, you can zoom in on the y-axis. To do so, click inside the scope window, or click and drag your cursor along the y-axis over your area of interest. |
| Tools > Pan | N/A | You access the Pan button from the menu under the Zoom In icon. When this tool is active, you can pan on the scope window. To do so, click in the center of your area of interest and drag your cursor to the left, right, up, or down, to move the position of the display. |
| Tools > Scale Y-Axis Limits | Ctrl+A | Click this button to scale the axes in the active scope window. Alternatively, you can enable automatic axes scaling by selecting one of the following options from the Tools menu:
|
| Tools > Scale X-Axis Limits | N/A | You access the Scale X-Axis Limits button from the menu under the current Axis Limits icon. Click this button to scale the axes in the X direction in the active scope window. Alternatively, you can enable automatic axes scaling by selecting one of the following options from the Tools menu:
|
| Tools > Scale X & Y Axes Limits | N/A | You access the Scale X & Y Axes Limits button from the menu under the current Axis Limits icon. Click this button to scale the axes in both the X and Y directions in the active scope window. Alternatively, you can enable automatic axes scaling by selecting one of the following options from the Tools menu:
|
| Tools > Measurements > Cursor Measurements | N/A | Open or close the Cursor Measurements panel. This panel puts screen cursors on the display. See the Cursor Measurements Panel section for more information. |
| Tools > Measurements > Signal Statistics | N/A | Open or close the Signal Statistics panel. This panel displays the maximum, minimum, peak-to-peak difference, mean, median, RMS values of a selected signal, and the times at which the maximum and minimum occur. See the Signal Statistics Panel section for more information. |
| Tools > Measurements > Peak Finder | N/A | Open or close the Peak Finder panel. This panel displays maxima and the frequencies at which they occur, allowing the settings for peak threshold, maximum number of peaks, and peak excursion to be modified. See the Peak Finder Panel section for more information. |
Note: The zoom buttons do not change the settings related to span for the scope. These buttons are purely graphical. |
You can control whether this toolbar appears in the Array Plot window. From the menu, select View > Toolbar.
The Measurements panels are the panels that appear to the right side of the Array Plot figure. These panels are labeled Trace selection, Cursor Measurements, Signal Statistics, and Peak Finder.
Each of the Measurements panels contains the following buttons that enable you to modify the appearance of the current panel.
Button | Description |
---|---|
| Move the current panel to the top. When you are displaying more than one panel, this action moves the current panel above all the other panels. |
| Collapse the current panel. When you first enable a panel,
by default, it displays one or more of its panes. Click this button
to hide all of its panes to conserve space. After you click this button,
it becomes the expand button
![]() |
| Expand the current panel. This button appears after you click
the collapse button to hide the panes in the current panel. Click
this button to display the panes in the current panel and show measurements
again. After you click this button, it becomes the collapse button
![]() |
| Undock the current panel. This button lets you move the current
panel into a separate window that can be relocated anywhere on your
screen. After you click this button, it becomes the dock button
![]() |
| Dock the current panel. This button appears only after you
click the undock button. Click this button to put the current panel
back into the right side of the Scope window. After you click this
button, it becomes the undock button
![]() |
| Close the current panel. This button lets you remove the current panel from the right side of the Scope window. |
Some panels have their measurements separated by category into
a number of panes. Click the pane expand button
to show each pane that
is hidden in the current panel. Click the pane collapse button
to hide each pane that
is shown in the current panel.
When you use the scope to view multiple signals, the Trace Selection panel appears if you have more than one signal displayed and you click any of the other Measurements panels. The Measurements panels display information about only the signal chosen in this panel. Choose the signal name for which you would like to display time domain measurements. See the following figure.
You can choose to hide or display the Trace Selection panel. In the Scope menu, select Tools > Measurements > Trace Selection.
The Cursor Measurements panel displays screen cursors. The panel provides two types of cursors for measuring signals. Waveform cursors are vertical cursors that track along the signal. Screen cursors are both horizontal and vertical cursors that you can place anywhere in the display.
Note: If a data point in your signal has more than one value, the cursor measurement at that point is undefined and no cursor value is displayed. |
In the Scope menu, select Tools > Measurements > Cursor Measurements. Alternatively, in the Scope toolbar, click the Cursor
Measurements
button.
The Cursor Measurements panel is separated into two panes, labeled Settings and Measurements. You can expand each pane to see the available options.
You can use the mouse or the left and right arrow keys to move vertical or waveform cursors and the up and down arrow keys for horizontal cursors.
The Signal Statistics panel
displays the maximum, minimum, peak-to-peak difference, mean, median,
and RMS values of a selected signal. It also shows the x-axis
indices at which the maximum and minimum values occur. You can choose
to hide or display the Signal Statistics panel.
In the scope menu, select Tools > Measurements > Signal Statistics. Alternatively, in the scope toolbar, click the Signal
Statistics
button.
Signal Statistics Measurements
When you use the zoom options in the scope, the Signal Statistics measurements automatically adjust to the time range shown in the display. In the scope toolbar, click the Zoom In or Zoom X button to constrict the x-axis range of the display, and the statistics shown reflect this time range. For example, you can zoom in on one pulse to make the Signal Statistics panel display information about only that particular pulse.
The Signal Statistics measurements are valid for any units of the input signal. The letter after the value associated with each measurement represents the appropriate International System of Units (SI) prefix, such as m for milli-. For example, if the input signal is measured in volts, an m next to a measurement value indicates that this value is in units of millivolts.
Note: The Peak Finder panel requires a DSP System Toolbox™ or Simscape™ license. |
The Peak Finder panel displays
the maxima, showing the x-axis values at which
they occur. Peaks are defined as a local maximum where lower values
are present on both sides of a peak. Endpoints are not considered
to be peaks. This panel allows you to modify the settings for peak
threshold, maximum number of peaks, and peak excursion. You can choose
to hide or display the Peak Finder panel. In
the scope menu, select Tools > Measurements > Peak Finder. Alternatively, in the scope toolbar, select the Peak
Finder
button.
The Peak finder panel is separated into two panes, labeled Settings and Peaks. You can expand each pane to see the available options.
The Settings pane enables you to modify
the parameters used to calculate the peak values within the displayed
portion of the input signal. For more information on the algorithms
this pane uses, see the Signal Processing Toolbox findpeaks
function
reference.
Peak Threshold — The level
above which peaks are detected. This setting is equivalent to the MINPEAKHEIGHT
parameter,
which you can set when you run the findpeaks
function.
Max Num of Peaks — The
maximum number of peaks to show. The value you enter must be a scalar
integer from 1 through 99. This setting is equivalent to the NPEAKS
parameter,
which you can set when you run the findpeaks
function.
Min Peaks Distance — The
minimum number of samples between adjacent peaks. This setting is
equivalent to the MINPEAKDISTANCE
parameter,
which you can set when you run the findpeaks
function.
Peak Excursion — The minimum
height difference between a peak and its neighboring samples The peak
excursion setting is equivalent to the THRESHOLD
parameter,
which you can set when you run the findpeaks
function.
Label Format — The coordinates to display next to the calculated peak values on the plot. To see peak values, expand the Peaks pane and select the check boxes associated with individual peaks of interest. By default, both x-axis and y-axis values are displayed on the plot. Select which axes values you want to display next to each peak symbol on the display.
X+Y
— Display both x-axis
and y-axis values.
X
— Display only x-axis
values.
Y
— Display only y-axis
values.
The Peaks pane displays all of the largest calculated peak values. It also shows the coordinates at which the peaks occur, using the parameters you define in the Settings pane. You set the Max Num of Peaks parameter to specify the number of peaks shown in the list.
The numerical values displayed in the Value column
are equivalent to the pks
output argument returned
when you run the findpeaks
function. The numerical
values displayed in the second column are similar to the locs
output
argument returned when you run the findpeaks
function.
The Peak Finder displays the peak values in the Peaks pane.
By default, the Peak Finder panel displays the
largest calculated peak values in the Peaks pane
in decreasing order of peak height. Use the sort descending button
(
) to rearrange
the category and order by which Peak Finder displays peak values.
Click this button again to sort the peaks in ascending order instead.
When you do so, the arrow changes direction to become the sort ascending
button (
). A filled
sort button indicates that the peak values are currently sorted in
the direction of the button arrow. If the sort button is not filled
(
), then the peak values
are sorted in the opposite direction of the button arrow. The Max
Num of Peaks parameter still controls the number of peaks
listed.
Use the check boxes to control which peak values are shown on the display. By default, all check boxes are cleared and the Peak Finder panel hides all the peak values. To show all the peak values on the display, select the check box in the top-left corner of the Peaks pane. To hide all the peak values on the display, clear this check box. To show an individual peak, select the check box directly to the left of its Value listing. To hide an individual peak, clear the check box directly to the left of its Value listing.
The Peaks are valid for any units of the input signal. The letter after the value associated with each measurement indicates the abbreviation for the appropriate International System of Units (SI) prefix, such as m for milli-. For example, if the input signal is measured in volts, an m next to a measurement value indicates that this value is in units of millivolts.
The Visuals—Array Plot Properties dialog box controls various properties about the Array Plot display. From the Array Plot menu, select View > Configuration Properties to open this dialog box.
The Main pane of the Visuals—Array Plot Properties dialog box appears as follows.
Specify the spacing between samples along the x-axis as a finite numeric scalar value.
Specify the offset to apply to the x-axis. This property is a numeric scalar. This property is Tunable.
Specify 'Linear'
or 'Log'
as
the x-axis scale . If XOffset
is
a negative value, you cannot set XScale
to 'Log'
. Tunable
Specify whether to display the scope in maximized axes mode. In this mode, each of the axes is expanded to fit into the entire display. To conserve space, labels do not appear in the display. Instead, tick-mark values appear on top of the plotted data. You can select one of the following options:
Auto
— In this mode,
the axes appear maximized only if the Title
and YLabel
properties
are empty. If you enter any value for either of these properties,
the axes are not maximized.
On
— In this mode,
the axes appear maximized. Any values entered into the Title
and YLabel
properties
are hidden.
Off
— In this mode,
none of the axes appear maximized.
This property is Tunable.
The Display pane of the Visuals—Array Plot Properties dialog box appears as follows.
Specify the display title as a character vector. Enter %<SignalLabel>
to
use the signal labels in the Simulink Model as the axes titles. This
property is Tunable.
Select this check box to show the legend in the display. The channel legend displays a name for each channel of each input signal. When the legend appears, you can place it anywhere inside the scope window. To turn off the legend, clear the Show legend check box. If the signal has multiple channels, the scope uses an index number to identify each signal channel. You can edit the name of any channel by double-clicking the current channel name and entering a new name. Tunable
When you select this check box, a grid appears in the display of the scope figure. To hide the grid, clear this check box. Tunable
When you select this check box, the scope splits the display into a magnitude plot and a phase plot. By default, this check box is cleared. If the input signal has complex values, the scope plots the real and imaginary portions on the same axes. These real and imaginary portions appear as different-colored lines on the same axes, as shown in the following figure.
Selecting this check box and clicking the Apply or OK button changes the display. The magnitude of the input signal appears on the top axes and its phase, in degrees, appears on the bottom axes. See the following figure.
This feature is useful for complex-valued input signals. If the input is a real-valued signal, selecting this check box returns the absolute value of the signal for the magnitude. The phase is 0 degrees for nonnegative input and 180 degrees for negative input. Tunable
Specify the text for the scope to display below the x-axis. This property is Tunable.
Specify the text for the scope to display to the left of the y-axis. Tunable
Specify the minimum value of the y-axis. Tunable
Specify the maximum value of the y-axis. Tunable
In the Style dialog box, you can customize the style of displays. You are able to change the color of the figure containing the displays, the background and foreground colors of display axes, and properties of lines in a display. From the scope menu, select View > Style to open this dialog box.
The Style dialog box allows you to modify the following properties of the scope figure:
Specify the color that you want to apply to the background of the scope figure. By default, the figure color is gray.
Specify the type of plot to use for all the input signals displayed in the scope window.
When you set this property to 'Stem'
,
the scope displays the input signal as circles with vertical lines
extending down to the x-axis at each of the sampled
values . This approach is similar to the functionality of the MATLAB stem
function.
When you set this property to 'Line'
,
the scope displays the input signal as lines connecting each of the
sampled values. This approach is similar to the functionality of
the MATLAB line
or plot
function.
When you set this property to 'Stairs'
,
the scope displays the input signal as a stairstep graph.
A stairstep graph is made up of only horizontal lines and vertical
lines. Each horizontal line represents the signal value for a discrete
sample period and is connected to two vertical lines. Each vertical
line represents a change in values occurring at a sample. This approach
is equivalent to the MATLAB stairs
function.
Stairstep graphs are useful for drawing time history graphs of digitally
sampled data.
This property is Tunable.
The default setting is Stem
.
Specify the color that you want to apply to the background of the axes.
Specify the channel for which you want to modify the visibility, line properties, and marker properties.
Specify whether the selected channel should be visible. If you clear this check box, the line disappears.
Specify the line style, line width, and line color for the selected channel.
Specify marks for the selected channel to show at its data points.
This parameter is similar to the Marker
property
for plot objects. You can choose any of the marker symbols from the
dropdown.
The Tools—Plot Navigation Properties dialog box allows you to automatically zoom in on and zoom out of your data. You can also scale the axes of the scope. In the scope menu, select Tools > Axes Scaling Properties to open this dialog box.
The Tools—Plot Navigation Properties dialog box appears as follows.
Specify when the scope automatically scales the axes. You can select one of the following options:
Manual
— When you
select this option, the scope does not automatically scale the axes.
You can manually scale the axes in any of the following ways:
Select Tools > Axes Scaling Properties.
Press one of the Scale Axis Limits toolbar buttons.
When the scope figure is the active window, press Ctrl and A simultaneously.
Auto
— When you
select this option, the scope scales the axes as needed, both during
and after simulation. Selecting this option shows the Do
not allow Y-axis limits to shrink check box.
After N Updates
—
Selecting this option causes the scope to scale the axes after a specified
number of updates. This option is useful and more efficient when your
scope display starts with one axis scale, but quickly reaches a different
steady state axis scale. Selecting this option shows the Number
of updates edit box.
By default, this property is set to Auto
.
This property is Tunable.
By default, this parameter is set to Manual
.
When you select this property, the y-axis is allowed only to grow during axes scaling operations. If you clear this check box, the y-axis or color limits may shrink during axes scaling operations.
This property appears only when you select Auto
for
the Axis scaling property. When you set the Axes
scaling property to Manual
or After
N Updates
, the y-axis or color limits
are allowed to shrink. Tunable.
Specify as a positive integer the number of updates after which
to scale the axes, or for the spectrogram, the color. This property
appears only when you select After N Updates
for
the Axes scaling or Color scaling property. Tunable.
Select this check box to scale the axes when the simulation stops. The y-axis is always scaled. The x-axis limits are only scaled if you also select the Scale X-axis limits check box.
Set the percentage of the y-axis that the
scope uses to display the data when scaling the axes. Valid values
are from 1 through 100. For example, if you set this property to 100
,
the Scope scales the y-axis limits such that your
data uses the entire y-axis range. If you then
set this property to 30
, the scope increases
the y-axis range such that your data uses only
30% of the y-axis range. Tunable.
Specify where the scope aligns your data along the y-axis
when it scales the axes. You can select Top
, Center
,
or Bottom
. Tunable.
Check this box to allow the scope to scale the x-axis
limits when it scales the axes. If Axes scaling is
set to Auto
, checking Autoscale
X-axis limits only scales the data currently within the
axes, not the entire signal in the data buffer. If Autoscale
X-axis limits is on and the resulting axis is greater than
the span of the scope, trigger position markers will not be displayed.
Triggers are controlled using the Trigger Measurements panel. Tunable.
Specify how the scope aligns your data along the x-axis: Left
, Center
,
or Right
. This property appears only when
you select the Scale X-axis limits check box. Tunable.