Skip to Main Content Skip to Search
Product Documentation

plot::SparseMatrixplotsparsity pattern of a matrix

plot::SparseMatrixplot(A) creates a 2D plot with the axes representing the rows and columns of the matrix A. For each nonzero entry of A a point is plotted, thus displaying sparsity patterns in the matrix.

→ Examples

Calls:

plot::SparseMatrixplot(A, Options)

plot::SparseMatrixplot(A, x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

plot::SparseMatrixplot([row1, row2, ...], Options)

plot::SparseMatrixplot([row1, row2, ...], x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

Parameters:

A

a matrix of category Cat::Matrix or an array containing real numerical values or expressions of the animation parameter a
A is equivalent to the attribute Data.

row1, row2, ...: 

the matrix rows: each row must be a list of real numerical values or expressions of the animation parameter a. All rows must have the same length. 
row1, row2, ... is equivalent to the attribute Data.

x

name of the horizontal coordinate: an identifier or an indexed identifier. It is used as the title of the coordinate axis in x direction. 
x is equivalent to the attribute XName.

`x_{min}` .. `x_{max}`

the range of the horizontal coordinate: `x_{min}`, `x_{max}` must be numerical real value or expressions of the animation parameter a
`x_{min}` .. `x_{max}` is equivalent to the attributes XRange, XMin, XMax.

y

name of the vertical coordinate: an identifier or an indexed identifier. It is used as the title of the coordinate axis in y direction. 
y is equivalent to the attribute YName.

`y_{min}` .. `y_{max}`

the range of the vertical coordinate: `y_{min}`, `y_{max}` must be numerical real value or expressions of the animation parameter a
`y_{min}` .. `y_{max}` is equivalent to the attributes YRange, YMin, YMax.

See Also:

plot, plot::copy, plot::Density, plot::Matrixplot, plot::Raster

Details:

Example 1

We create a random matrix of dimension 100 x 200 with 1000 nonzero entries:

A := matrix::random(100, 200, 1000, frandom):
plot(plot::SparseMatrixplot(A))

MuPAD graphics

With PointColorType = Dichromatic, the color of the points indicates the size of the matrix entries:

plot(plot::SparseMatrixplot(A, PointColorType = Dichromatic)):

MuPAD graphics

delete A:

Example 2

Choosing appropriate coordinate ranges, we let two sparse matrix plots overlap each other. The red points correspond to a sparse 10 x 10 matrix with 50 random entries. The blue points indicate the corresponding upper triangular form obtained by Gaussian elimination:

A := matrix::random(10, 10, 50, random(1..5)):
B := A::dom::gaussElim(A)[1]:
plot(plot::SparseMatrixplot(A, x = 1..10, y = 1..10,
                            Color = RGB::Red),
     plot::SparseMatrixplot(B, x = 1.3..10.3, y = 1..10,
                            Color = RGB::Blue,
                            PointStyle = FilledCircles),
     PointSize = 2*unit::mm, Scaling = Constrained,
     Axes = Frame)

MuPAD graphics

delete A, B:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS