Saturday, July 25, 2009

compan

Companion matrix

Syntax

*

A = compan(u)

Description


A = compan(u) returns the corresponding companion matrix whose first row is -u(2:n)/u(1), where u is a vector of polynomial coefficients. The eigenvalues of compan(u) are the roots of the polynomial.

Examples

The polynomial

has a companion matrix given by

*

u = [1 0 -7 6]
A = compan(u)
A =
0 7 -6
1 0 0
0 1 0

The eigenvalues are the polynomial roots:

*

eig(compan(u))

ans =
-3.0000
2.0000
1.0000

This is also roots(u).


compass

Plot arrows emanating from the origin

Syntax

*

compass(X,Y)
compass(Z)
compass(...,LineSpec)
h = compass(...)

Description

A compass plot displays direction or velocity vectors as arrows emanating from the origin. X, Y, and Z are in Cartesian coordinates and plotted on a circular grid.

compass(X,Y) displays a compass plot having n arrows, where n is the number of elements in X or Y. The location of the base of each arrow is the origin. The location of the tip of each arrow is a point relative to the base and determined by [X(i),Y(i)].

compass(Z) displays a compass plot having n arrows, where n is the number of elements in Z. The location of the base of each arrow is the origin. The location of the tip of each arrow is relative to the base as determined by the real and imaginary components of Z. This syntax is equivalent to compass(real(Z),imag(Z)).

compass(...,LineSpec) draws a compass plot using the line type, marker symbol, and color specified by LineSpec.

h = compass(...) returns handles to line objects.

Examples

Draw a compass plot of the eigenvalues of a matrix.

*

Z = eig(randn(20,20));
compass(Z)



complex

Construct complex data from real and imaginary components

Syntax

*

c = complex(a,b)
c = complex(a)

Description


c = complex(a,b) creates a complex output, c, from the two real inputs.

*

c = a + bi

The output is the same size as the inputs, which must be scalars or equally sized vectors, matrices, or multi-dimensional arrays of the same data type.

Note If b is all zeros, c is complex and the value of all its imaginary components is 0. In contrast, the result of the addition a+0i returns a strictly real result.

c = complex(a) for real a returns the complex result c with real part a and 0 as the value of all imaginary components. Even though the value of all imaginary components is 0, c is complex and isreal(c) returns false.

The complex function provides a useful substitute for expressions such as

*

a + i*b or a + j*b

in cases when the names "i" and "j" may be used for other variables (and do not equal ), when a and b are not double-precision, or when b is all zero.

Example

Create complex uint8 vector from two real uint8 vectors.

*

a = uint8([1;2;3;4])
b = uint8([2;2;7;7])
c = complex(a,b)
c =
1.0000 + 2.0000i
2.0000 + 2.0000i
3.0000 + 7.0000i
4.0000 + 7.0000i


computer

Identify information about computer on which MATLAB is running

Syntax

*

str = computer
[str,maxsize] = computer
[str,maxsize,endian] = computer

Description

str = computer returns the string str with the computer type on which MATLAB is running.

[str,maxsize] = computer returns the integer maxsize, which contains the maximum number of elements allowed in an array with this version of MATLAB.

[str,maxsize,endian] = computer also returns either 'L' for little endian byte ordering or 'B' for big endian byte ordering.

The list of supported computers changes as new computers are added and others become obsolete. A typical list follows.

str Computer

ALPHA Compaq Alpha (OSF1)

HP700 HP 9000/700 (HP-UX 10.20)

HPUX HP PA-RISC (HP-UX 11.00)

IBM_RS IBM RS6000 workstation (AIX)

GLNX86 Linux on PC

PCWIN Microsoft Windows

SGI Silicon Graphics (IRIX/IRIX64)

SOL2 Sun Solaris 2 SPARC workstation

Remarks

SGI64 users prior to R12 must migrate to SGI with R12. LNX86 users prior to R12 must migrate to GLNX86 with R12.

No comments:

Post a Comment