Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

dsp.ArrayPlot System object

Display vectors or arrays

Description

The dsp.ArrayPlot System object™ displays vectors or arrays.

To display vectors or array on the Array Plot:

  1. Create the dsp.ArrayPlot object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

Creation

Syntax

scope = dsp.ArrayPlot
scope = dsp.ArrayPlot(Name,Value)

Description

example

scope = dsp.ArrayPlot creates an Array Plot System object, scope.

scope = dsp.ArrayPlot(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in single quotes. For example, scope = dsp.ArrayPlot('NumInputPorts',3)

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).

Plot Configuration

Number of input ports, specified as a positive integer. Each signal coming through an input port becomes a separate channel in the scope. You must invoke the scope with the same number of inputs as the value of this property.

Specify whether to use the SampleIncrement and XOffset property values to determine spacing, or specify your own custom spacing. If you specify 'Custom', you also must specify the CustomXData property values.

UI Use

Open the Configuration Properties. On the Main tab, set X-data mode.

Specify the desired x-data values as a row or column vector of length equal to the frame length of the inputs. If you use the default (empty vector) value, the x-data is uniformly spaced and set to (0:L–1), where L is the frame length.

Example: scope = dsp.ArrayPlot('XDataMode','Custom', 'CustomXData',logspace(0,log10(44100/2),1024))

UI Use

Open the Configuration Properties. On the Main tab, set Custom X-Data.

Dependency

To use this property, set XDataMode to 'Custom'.

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 XOffset and SampleIncrement properties. For example, when Xoffset is 0 and SampleIncrement is 1, the x-data for the input signal is set to 0, 1, 2, 3, 4, etc. If you set SampleIncrement to 0.25, the x-axis data becomes 0, 0.25, 0.5, 0.75, 1, etc.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Main tab, set Sample increment.

Specify the offset to display on the x-axis. This property is a scalar

Tunable: Yes

UI Use

Open the Configuration Properties. On the Main tab, set X-offset.

Specify whether the scale of the x-axis is 'Linear' or 'Log'. If XOffset is a negative value, you cannot set this property to 'Log'.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Main tab, set X-axis scale.

Specify the type of plot to use for all the input signals displayed in the scope window:

  • '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 option is similar to the stem function.

  • 'Line' – The scope displays the input signal as lines connecting each of the sampled values. This option is similar to the line or plot functions.

  • '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 option is similar to the stairs function. Stairstep graphs are useful for drawing time history graphs of digitally sampled data.

UI Use

Open the Style dialog box and set Plot type.

Specify when the scope scales the axes. Valid values are:

  • 'Auto' — The scope scales the axes as needed to fit the data, both during and after simulation.

  • 'Manual' — The scope does not scale the axes automatically.

  • 'OnceAtStop' — The scope scales the axes when the simulation stops.

  • 'Updates' — The scope scales the axes once and only once after 10 updates.

UI Use

Select Tools > Axes Scaling.

Visualization

Specify the name of the scope as a character vector. 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

Specify, in pixels, the size and location of the scope window as a four-element vector of the form [left bottom width height]. By default, the scope window appears in the center of your screen with a width of 800 pixels and height of 450 pixels. The default values for this property may change depending on your screen resolution.

  • true — The scope logs data for later use and updates the window periodically.

  • false — The scope updates every time the scope is called.

The simulation speed is faster when this property is set to true.

Tunable: Yes

UI Use

Select Simulation > Reduce Updates to Improve Performance.

Specify whether to display the scope in 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, tick-mark 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.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Main tab, set Maximize axes.

Specify the display title as a character vector or string. Enter %<SignalLabel> to use the signal labels as the axes titles.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Display tab, set Title.

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

From the legend, you can control which signals are visible. This control is equivalent to changing the visibility in the Style dialog box. In the scope legend, click a signal name to hide the signal in the scope. To show the signal, click the signal name again. To show only one signal, right-click the signal name. To show all signals, press Esc.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Display tab, select Show legend.

Specify the input channel names as a cell array of character vectors or strings. The names appear in the legend, Style dialog box, and Measurements panels. If you do not specify names, the channels are labeled as Channel 1, Channel 2, etc.

Tunable: Yes

Dependency

To see channel names, set ShowLegend to true.

UI Use

Show the legend and double-click the channel name.

Set this property to true to show gridlines on the plot.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Display tab, set Show grid.

When you set this property to true, the scope plots the magnitude and phase of the input signal on two separate axes within the same active display. When you set this property to 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.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Display tab, select Plot signals as magnitude and phase.

Specify the text for the scope to display below the x-axis.

Tunable: Yes

UI Use

Open the Configuration Properties. On the Display tab, set X-label.

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

Tunable: Yes

Dependencies

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

UI Use

Open the Configuration Properties. On the Display tab, set Y-Label.

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 false, the default is [0,10].

Tunable: Yes

Dependencies

When PlotAsMagnitudePhase is true, this property specifies the y-axis limits of only the magnitude plot. The y-axis limits of the phase plot are always [-180,180].

UI Use

Open the Configuration Properties. On the Display tab, set Y-limits (Minimum) and Y-limits (Maximum).

Usage

For versions earlier than R2016b, use the step function to run the System object™ algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Syntax

scope(signal)
scope(signal1,signal2,...,signalN)

Description

example

scope(signal) displays the signal in the Array Plot.

scope(signal1,signal2,...,signalN) displays multiple signals in the Array Plot. The signals must have the same frame length, but can vary in number of channels. You must set the NumInputPorts property to enable multiple input signals.

Input Arguments

expand all

Specify one or more input signals to visualize in the dsp.ArrayPlot. Signals can have a different number of channels, but they must have the same frame length.

Example: scope(signal1, signal2)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | struct | table | cell | categorical | datetime | fi

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)
showDisplay scope window
hideHide scope window
stepRun System object algorithm
cloneCreate duplicate System object
getNumInputsNumber of inputs required to call the System object
getNumOutputsNumber of outputs from calling the System object
isLockedDetermine if System object is locked
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the object with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Create a new Array Plot object.

scope = dsp.ArrayPlot;

Configure the properties of the Array Plot object for a Gaussian distribution.

scope.YLimits = [0 1];
scope.XOffset = -2.5;
scope.SampleIncrement = 0.1;
scope.Title = 'Gaussian distribution';
scope.XLabel = 'X';
scope.YLabel = 'f(X)';

Call the Array Plot object to plot a Gaussian distribution.

scope(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 object 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.

lmsFilter = dsp.LMSFilter(40,'Method','Normalized LMS','StepSize',0.002);

Create and configure a dsp.AudiFileReader System object to read the input signal from the specified audio file.

signalSource = dsp.AudioFileReader('dspafxf_8000.wav',...
    'SamplesPerFrame',40, ...
    'PlayCount',Inf,...
    'OutputDataType','double');

Create and configure a dsp.FIRFilter System object to filter random white noise, creating colored noise.

firFilter = dsp.FIRFilter('Numerator',fir1(39,0.25));

Create and configure an Array Plot System object to display the adaptive filter weights.

scope = dsp.ArrayPlot('XLabel','Filter Tap', ...
    'YLabel','Filter Weight', ...
    'YLimits',[-0.05 0.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]    = signalSource();
    noise       = rand(40,1);
    noisefilt   = firFilter(noise);
    desired     = y + noisefilt;
    [~, ~, wts] = lmsFilter(noise,desired);
    scope(wts);
    numplays = numplays + eof;
end

Tips

  • To close the Array Plot window and clear its associated data, use the MATLAB® clear function.

  • To hide or show the Array Plot window, use the hide and show functions.

  • Use the MATLAB mcc function to compile code containing an Array Plot.

Extended Capabilities

Introduced in R2013a

Was this topic helpful?