Display matrices as color images
Sinks
dspsnks4
The Matrix Viewer block displays an MbyN matrix input by mapping the matrix element values to a specified range of colors. The display is updated as each new input is received. This block treats an unoriented length M vector input as an Mby1 matrix.
You can use the Matrix Viewer block in models running in Normal or Accelerator simulation modes. The software does not support this block in models running in Rapid Accelerator or External mode. For more information about these modes, see How Acceleration Modes Work (Simulink) in the Simulink^{®} User's Guide.
Select the Image Properties tab to show the image property parameters, which control the colormap and display.
You specify the mapping of matrix element values to colors in the Colormap matrix, Minimum input value, and Maximum input value parameters. For a colormap with L colors, the colormap matrix has dimension Lby3, with one row for each color and one column for each element of the RGB triple that defines the color. Examples of RGB triples are
[ 1 0 0 ] (red) [ 0 0 1 ] (blue) [0.8 0.8 0.8] (light gray)
See the ColorSpec
property
in the MATLAB^{®} documentation for complete information about defining
RGB triples.
MATLAB provides a number of functions for generating predefined
colormaps, such as hot
, cool
, bone
,
and autumn
. Each of these functions accepts
the colormap size as an argument, and can be used in the Colormap
matrix parameter. For example, when you specify gray(128)
for
the Colormap matrix parameter, the matrix is
displayed in 128 shades of gray. The color in the first row of the
colormap matrix represents the value specified by the Minimum
input value parameter, and the color in the last row represents
the value specified by the Maximum input value parameter.
Values between the minimum and maximum are quantized and mapped to
the intermediate rows of the colormap matrix.
The documentation for the MATLAB colormap
function
provides complete information about specifying colormap matrices,
and includes a complete list of the available colormap functions.
Select the Axis Properties tab to show the axis property parameters, which control labeling and positioning.
The Axis origin parameter determines where
the first element of the input matrix, U(1,1),
is displayed. When you specify Upper left corner
,
the matrix is displayed in matrix orientation, with U(1,1)
in the upperleft corner.
$$\left[\begin{array}{cccc}{U}_{11}& {U}_{12}& {U}_{13}& {U}_{14}\\ {U}_{21}& {U}_{22}& {U}_{23}& {U}_{24}\\ {U}_{31}& {U}_{32}& {U}_{33}& {U}_{34}\\ {U}_{41}& {U}_{42}& {U}_{43}& {U}_{44}\end{array}\right]$$
When you specify Lower left corner
,
the matrix is flipped vertically to image orientation, with U(1,1)
in the lowerleft corner.
$$\left[\begin{array}{cccc}{U}_{41}& {U}_{42}& {U}_{43}& {U}_{44}\\ {U}_{31}& {U}_{32}& {U}_{33}& {U}_{34}\\ {U}_{21}& {U}_{22}& {U}_{23}& {U}_{24}\\ {U}_{11}& {U}_{12}& {U}_{13}& {U}_{14}\end{array}\right]$$
Axis zoom, when selected, causes the image display to completely fill the figure window. Axis titles are not displayed. This option can also be selected from the popup menu that is displayed when you rightclick in the figure window. When Axis zoom is cleared, the axis labels and titles are displayed in a gray border surrounding the image axes.
To customize the axis tick range, set Axis tick mode to Userdefined
and
specify a twoelement row vector, [Minvalue Maxvalue
],
in Xtick range and Ytick range.
The matrix data does not change even when the axes ticks change. For
example, consider displaying a matrix on axes with ticks ranging from
0 to 10. When you set Xtick range and Ytick
range to [0 1], the range of ticks changes from [0 10]
to [0 1].
The image title in the figure title bar is the same as the block title. The axis tick marks reflect the size of the input matrix; the xaxis is numbered from 1 to N (number of columns), and the yaxis is numbered from 1 to M (number of rows).
Rightclick the image in the figure window to access the following menu items:
Refresh erases all data on the scope display except for the most recent image.
Autoscale recomputes the minimum and maximum input values to fit the range of values observed in a series of 10 consecutive inputs. The numerical limits selected by the autoscale feature are shown in the Minimum input value and Maximum input value parameters, where you can make further adjustments to them manually.
Axis zoom, when selected, causes the image to completely fill the figure window. Axis titles are not displayed. When Axis zoom is cleared, the axis labels and titles are displayed in a gray border surrounding the scope axes. This option can also be set in the Axis Properties pane of the parameter dialog box.
Colorbar, when selected, displays a bar with the specified colormap to the right of the image axes.
Save Position automatically updates the Figure position parameter in the Axis Properties pane to reflect the figure window's current position and size on the screen. To make the scope window open at a particular location on the screen when the simulation runs, drag the window to the desired location, resize it, and select Save Position. The parameter dialog box must be closed when you select Save Position for the Figure position parameter to be updated.
The Image Properties pane of the Matrix Viewer block appears as follows.
A 3column matrix defining the colormap as a set of RGB triples,
or a call to a colormapgenerating function such as hot
or spring
.
See the ColorSpec
property
for complete information about defining RGB triples, and the MATLAB colormap
function for a list of colormapgenerating
functions. Tunable (Simulink).
The input value to be mapped to the color defined in the first
row of the colormap matrix. Rightclick in the figure window and select Autoscale
from
popup menu to set this parameter to the minimum value observed in
a series of 10 consecutive matrix inputs. Tunable (Simulink).
The input value to be mapped to the color defined in the last
row of the colormap matrix. Rightclick in the figure window and select Autoscale
from
the popup menu to set this parameter to the maximum value observed
in a series of 10 consecutive matrix inputs. Tunable (Simulink).
Select to display a bar with the selected colormap to the right of the image axes. Tunable (Simulink).
The Axis Properties pane of the Matrix Viewer block appears as follows.
The position within the axes where the first element of the input matrix, U(1,1), is plotted; bottom left or top left. Tunable (Simulink).
The mode used to specify the axis tick range. When you select Auto
,
the xaxis tick range and yaxis
tick range are chosen based on the input signal. When you select Userdefined
,
the axis tick range is set based on the values you specify in Xtick
range and Ytick range. The default
is Auto
.
xaxis tick range, specified as a twoelement
row vector of real scalars, [X_{min} X_{max}].
This parameter applies only when you set Axis tick mode to Userdefined
.
When you change Xtick range during simulation,
the axis range on the Matrix Viewer block updates in
real time. The default is [0 1
].
yaxis tick range, specified as a twoelement
row vector of real scalars, [Y_{min} Y_{max}].
This parameter applies only when you set Axis tick mode to Userdefined
.
When you change Ytick range during simulation,
the axis range on the Matrix Viewer block updates in
real time. The default is [0 1
].
The text to be displayed below the xaxis. Tunable (Simulink).
The text to be displayed to the left of the yaxis. Tunable (Simulink).
The text to be displayed to the right of the color bar, when Display colorbar is currently selected. Tunable (Simulink).
A 4element vector of the form [x y width height]
specifying
the position of the figure window, where (0,0)
is
the lowerleft corner of the display. Tunable (Simulink).
Resizes the image to fill the figure window. Tunable (Simulink).
Port  Supported Data Types 

Input 

Spectrum Analyzer  DSP System Toolbox 
Vector Scope  DSP System Toolbox 
colormap  MATLAB 
ColorSpec  MATLAB 
image  MATLAB 