Saturday, July 25, 2009

ColorSpec

Color specification

Description

ColorSpec is not a command; it refers to the three ways in which you specify color in MATLAB:

* RGB triple
* Short name
* Long name

The short names and long names are MATLAB strings that specify one of eight predefined colors. The RGB triple is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color; the intensities must be in the range [0 1]. The following table lists the predefined colors and their RGB equivalents.

RGB Value Short Name Long Name
[1 1 0] y yellow

[1 0 1] m magenta

[0 1 1] c cyan

[1 0 0] r red

[0 1 0] g green

[0 0 1] b blue

[1 1 1] w white

[0 0 0] k black

Remarks


The eight predefined colors and any colors you specify as RGB values are not part of a figure's colormap, nor are they affected by changes to the figure's colormap. They are referred to as fixed colors, as opposed to colormap colors.

Examples

To change the background color of a figure to green, specify the color with a short name, a long name, or an RGB triple. These statements generate equivalent results:

*

whitebg('g')
whitebg('green')
whitebg([0 1 0]);

You can use ColorSpec anywhere you need to define a color. For example, this statement changes the figure background color to pink:

*

set(gcf,'Color',[1,0.4,0.6])



colperm

Sparse column permutation based on nonzero count

Syntax


*

j = colperm(S)

Description


j = colperm(S) generates a permutation vector j such that the columns of S(:,j) are ordered according to increasing count of nonzero entries. This is sometimes useful as a preordering for LU factorization; in this case use lu(S(:,j)).

If S is symmetric, then j = colperm(S) generates a permutation j so that both the rows and columns of S(j,j) are ordered according to increasing count of nonzero entries. If S is positive definite, this is sometimes useful as a preordering for Cholesky factorization; in this case use chol(S(j,j)).

Algorithm

The algorithm involves a sort on the counts of nonzeros in each column.

Examples

The n-by-n arrowhead matrix

*

A = [ones(1,n); ones(n-1,1) speye(n-1,n-1)]

has a full first row and column. Its LU factorization, lu(A), is almost completely full. The statement

*

j = colperm(A)

returns j = [2:n 1]. So A(j,j) sends the full row and column to the bottom and the rear, and lu(A(j,j)) has the same nonzero structure as A itself.

On the other hand, the Bucky ball example,

*

B = bucky

has exactly three nonzero elements in each row and column, so j = colperm(B) is the identity permutation and is no help at all for reducing fill-in with subsequent factorizations.



comet


Two-dimensional comet plot

Syntax

*

comet(y)
comet(x,y)
comet(x,y,p)

Description


A comet plot is an animated graph in which a circle (the comet head) traces the data points on the screen. The comet body is a trailing segment that follows the head. The tail is a solid line that traces the entire function.

comet(y) displays a comet plot of the vector y.

comet(x,y) displays a comet plot of vector y versus vector x.

comet(x,y,p) specifies a comet body of length p*length(y). p defaults to 0.1.

Remarks


Note that the trace left by comet is created by using an EraseMode of none, which means you cannot print the plot (you get only the comet head) and it disappears if you cause a redraw (e.g., by resizing the window).

Examples

Create a simple comet plot:

*

t = 0:.01:2*pi;
x = cos(2*t).*(cos(t).^2);
y = sin(2*t).*(sin(t).^2);
comet(x,y);


comet3


Three-dimensional comet plot

Syntax


*

comet3(z)
comet3(x,y,z)
comet3(x,y,z,p)

Description


A comet plot is an animated graph in which a circle (the comet head) traces the data points on the screen. The comet body is a trailing segment that follows the head. The tail is a solid line that traces the entire function.

comet3(z) displays a three-dimensional comet plot of the vector z.

comet3(x,y,z) displays a comet plot of the curve through the points [x(i),y(i),z(i)].

comet3(x,y,z,p) specifies a comet body of length p*length(y).

Remarks


Note that the trace left by comet3 is created by using an EraseMode of none, which means you cannot print the plot (you get only the comet head) and it disappears if you cause a redraw (e.g., by resizing the window).

Examples

Create a three-dimensional comet plot.

*

t = -10*pi:pi/250:10*pi;
comet3((cos(2*t).^2).*sin(t),(sin(2*t).^2).*cos(t),t);

No comments:

Post a Comment