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 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.
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.
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 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.
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.
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.
Select to display a bar with the selected colormap to the right of the image axes. Tunable.
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.
The text to be displayed below the xaxis. Tunable.
The text to be displayed to the left of the yaxis. Tunable.
The text to be displayed to the right of the color bar, when Display colorbar is currently selected. Tunable.
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.
Resizes the image to fill the figure window. Tunable.
Port  Supported Data Types 

Input 

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