Documentation Center |
Eigenvalues and eigenvectors
d = eig(A)
d = eig(A,B)
[V,D] = eig(A)
[V,D] = eig(A,'nobalance')
[V,D] = eig(A,B)
[V,D] = eig(A,B,flag)
d = eig(A) returns a vector of the eigenvalues of matrix A.
d = eig(A,B) returns a vector containing the generalized eigenvalues, if A and B are square matrices.
Note If S is sparse and symmetric, you can use d = eig(S) to return the eigenvalues of S. If S is sparse but not symmetric, or if you want to return the eigenvectors of S, use the function eigs instead of eig. |
[V,D] = eig(A) produces matrices of eigenvalues (D) and eigenvectors (V) of matrix A, so that A*V = V*D. Matrix D is the canonical form of A — a diagonal matrix with A's eigenvalues on the main diagonal. Matrix V is the modal matrix — its columns are the eigenvectors of A.
[V,D] = eig(A,'nobalance') finds eigenvalues and eigenvectors without a preliminary balancing step. This may give more accurate results for certain problems with unusual scaling. Ordinarily, balancing improves the conditioning of the input matrix, enabling more accurate computation of the eigenvectors and eigenvalues. However, if a matrix contains small elements that are really due to roundoff error, balancing may scale them up to make them as significant as the other elements of the original matrix, leading to incorrect eigenvectors. Use the nobalance option in this event. See the balance function for more details.
[V,D] = eig(A,B) produces a diagonal matrix D of generalized eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that A*V = B*V*D .
[V,D] = eig(A,B,flag) specifies the algorithm used to compute eigenvalues and eigenvectors. flag can be:
Computes the generalized eigenvalues of A and B using the Cholesky factorization of B. This is the default for symmetric (Hermitian) A and symmetric (Hermitian) positive definite B. | |
Ignores the symmetry, if any, and uses the QZ algorithm as it would for nonsymmetric (non-Hermitian) A and B. |
The matrix
B = [ 3 -2 -.9 2*eps
-2 4 1 -eps
-eps/4 eps/2 -1 0
-.5 -.5 .1 1 ];has elements on the order of roundoff error. It is an example for which the nobalance option is necessary to compute the eigenvectors correctly. Try the statements
[VB,DB] = eig(B) B*VB - VB*DB [VN,DN] = eig(B,'nobalance') B*VN - VN*DN