Main Content

dsp.MatrixViewer

Visualize matrix data

Description

The dsp.MatrixViewer visualizes matrix data by mapping the matrix elements to a specified range of colors.

To visualize matrix data in the Matrix Viewer:

  1. Create the dsp.MatrixViewer 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?

Zoom and Pan

To scale the plot axes, you can use the scroll button on your mouse to zoom in/out of the plot and CTRL+Click and drag to pan around the plot. Additionally, you can use the buttons that appear when you hover over the upper right corner of the plot window.

  • — Autoscale the axes to fit the data.

  • — Zoom in to the plot.

  • — Pan around the axes.

Cursor Measurements

Activate cursor measurements by hovering over the matrix viewer and selecting the cursor button .

Two horizontal and two vertical cursors appear on the plot. A dialog box shows the difference between the two intersection points. Hovering over an intersection point shows the value at that intersection point. Move the cursors by clicking and dragging the cursor lines or the intersection points to your desired location. Additionally, you can Alt+Click and drag the cursor dialog box to move the cursors while keeping the distance between the cursor lines constant.

Creation

Description

scope = dsp.MatrixViewer creates a Matrix Viewer System object™, scope.

example

scope = dsp.MatrixViewer(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in single quotes. For example, scope = dsp.MatrixViewer("AxisOrigin","Lower left corner")

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.

Matrix Information

Specify the x-axis numbering mode.

  • "Offset and resolution" – Compute the x-axis data points from the XResolution and XOffset properties.

  • "Custom" – Compute the x-axis data points using the CustomXData property.

Data Types: char | string

Specify the y-axis numbering mode:

  • "Span and resolution" – Compute the y-axis data points from the YSpan and YResolution properties.

  • "Offset and resolution" – Compute the y-axis data points from the YResolution and YOffset properties.

  • "Custom" – Compute the y-axis data points using the CustomYData property.

Data Types: char | string

Specify custom values for the x-axis using a two-element numeric vector or a numeric vector with a finite number of elements.

If you specify a two-element vector, the numbers are used as the min and max values of the x-axis. If you specify a vector with more than two elements, the values must be monotonically increasing and the scope uses the first and last values of the vector as the minimum and maximum values, respectively. If you do not specify x-axis data limits, the scope uses the number of input columns as the maximum x-axis value.

Example: [5 156]

Tunable: Yes

Dependency

To enable this property, you must set XDataMode to "Custom".

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

Specify custom values for the y-axis using a two-element numeric vector or a numeric vector with a finite number of elements.

If you specify a two-element vector, the numbers are used as the min and max values of the y-axis. If you specify a vector with more than two elements, the values must be monotonically increasing and the scope uses the first and last values of the vector as minimum and maximum values, respectively. If you do not specify y-axis data limits, the scope uses the number of input rows as the maximum y-axis value.

Example: [-130 10]

Tunable: Yes

Dependency

To enable this property, you must set YDataMode to "Custom".

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

Specify the offset to display on the x-axis as a scalar.

Tunable: Yes

Dependency

To enable this property, you must set XDataMode to "Offset and resolution".

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

Specify the spacing of values along the x-axis as a scalar.

Tunable: Yes

Dependency

To enable this property, you must set XDataMode to "Offset and resolution".

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

Specify the offset to display on the y-axis as a scalar.

Tunable: No

Dependency

To enable this property, you must set YDataMode to "Offset and resolution".

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

Specify the spacing of values along the y-axis as a scalar.

Tunable: No

Dependency

To enable this property, you must set YDataMode to "Offset and resolution" or "Span and resolution".

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

Specify the span of values along the y-axis as a scalar.

Tunable: No

Dependency

To enable this property, you must set YDataMode to "Span and resolution".

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

Visualization

Specify the name of the scope. This name appears as the title of the scope's figure window. To specify the title of plot, use the Title property.

Data Types: char | string

Specify the starting location of the plot. If you specify "Upper left corner", the plot starts in the top left corner of the axes and continues down.

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 410 pixels and height of 300 pixels. The default values for this property may change depending on your screen resolution.

Specify the title of the plot as a character vector or string. By default, there is no title.

Tunable: Yes

Data Types: char | string

Specify the text for the scope to display below the x-axis. By default, the axes is unlabeled.

Tunable: Yes

Data Types: char | string

Specify the text for the scope to display to the left of the y-axis. By default, the axes is unlabeled.

Tunable: Yes

Data Types: char | string

Specify the text for the scope to display next to the color bar. By default, the color bar is unlabeled.

Tunable: Yes

Data Types: char | string

Color scheme for the colormap, specified as a predefined colormap name or a three-column matrix of RGB triplets.

For a list of acceptable colormap names, see map.

To use a custom colormap, specify a three-column matrix of RGB triplets. You can create the RGB matrix yourself, or you can call a predefined colormap function, such as colormap, to create the matrix.

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

Specify the color bar limits as a two-element numeric vector [min max]. By default, limits are set as the minimum and maximum values of the input matrix.

Example: [1 80]

Tunable: Yes

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

Location of the color bar relative to the axes.

Tunable: Yes

Data Types: char | string

Set this property to false to hide the color bar on the plot.

Set this property to false to hide grid lines on the plot.

Tunable: Yes

Set this property to false to hide the ticks on the x-axis and y-axis.

Usage

Description

example

scope(matrix) displays the matrix by mapping matrix element values to a range of colors.

Input Arguments

expand all

Specify an n-by-m numeric matrix to visualize.

Example: scope(rand(3,5))

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

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)

expand all

setCursorDataLabelsCustomize data labels for cursor measurements
showDisplay scope window
hideHide scope window
isVisibleDetermine visibility of scope
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

This example shows how to create a spectrogram of a quadratic chirp with the dsp.MatrixViewer System object.

Set up the sample rate and a chirp signal.

Fs = 233e3;
frameSize = 20e3;
chirp = dsp.Chirp("SampleRate",Fs,"SamplesPerFrame",frameSize,...
  "InitialFrequency",11e3,"TargetFrequency",11e3+55e3,...
  "Type","Quadratic");

Create a dsp.MatrixViewer scope. Set the axis labels, select a colormap, and set the limits of the colormap.

scope = dsp.MatrixViewer(...
    "ColorBarLabel","Power/Frequency (dB/Hz)",...
    "XLabel","Frequency (Hz)",...
    "YLabel","Time (secs)",...
    "Colormap","hsv",...
    "ColorLimits",[-100,-30]);

Visualize the spectrogram of the chirp signal in the scope.

for idx = 1:50
    y = chirp() + 0.05*randn(frameSize,1);
    [~,~,~,Ps] = spectrogram(y,128,120,128,1e3);
    val = 10*log10(abs(Ps)'+eps);
    scope(val);
end

Version History

Introduced in R2019a