Eigenvectors and eigenvalues of a matrix. |
||
Syntax |
V, D = eig(A) V, D = eig(A, 'nobalance') V, D = eig(A, B) |
|
Argument |
Name |
Description |
A |
A square matrix (n-by-n); real or complex. |
|
B |
A square matrix (n-by-n); real or complex. |
|
Outputs |
Name |
Description |
V |
Eigenvectors (n-by-n). |
|
D |
Eigenvalues stored as a diagonal matrix (n-by-n). |
|
Example |
Syntax |
|
A = [2,1;3,4]; V1,D1 = eig(A) print('V1 = ', V1) print('D1 = ', D1) print('A*V1 - V1*D1 = ',A*V1 - V1*D1); VN,DN = eig(A, 'nobalance'); print('VN = ', VN) print('DN = ', DN) print('A*VN - VN*DN',A*VN - VN*DN) A = [1, 2; 3, 8]; B = [8, 3; 4, 3]; V2, D2 = eig (A, B) print('V2 = ', V2) print('D2 = ', D2) print('A*V2 - B*V2*D2 = ', A*V2 - B*V2*D2) |
||
Result |
||
V1 = [Matrix] 2 x 2 -0.70711 -0.31623 0.70711 -0.94868 D1 = [Matrix] 2 x 2 1 0 0 5 A*V1 - V1*D1 = [Matrix] 2 x 2 -4.4409e-016 0 -1.1102e-016 0 VN = [Matrix] 2 x 2 -0.70711 -0.31623 0.70711 -0.94868 DN = [Matrix] 2 x 2 1 0 0 5 A*VN - VN*DN = [Matrix] 2 x 2 0 0 0 0 V2 = [Matrix] 2 x 2 -1 -0.32423 0.36026 1 D2 = [Matrix] 2 x 2 0.040392 0 0 4.1263 A*V2 - B*V2*D2 = [Matrix] 2 x 2 -2.7756e-016 -3.3307e-015 2.6368e-016 8.8818e-016 |
||
Comments |
V, D = eig (A) computes a diagonal matrix D (eigenvalues) and a full matrix V (eigenvectors) so that A = V\V*D or A*V = V*D or Av = λv. The matrix V is the modal matrix and the matrix D is the canonical form of A. V, D = eig(A, nobalance) retrieves the eigenvectors and eigenvalues of A without balancing. The nobalance argument has no affect on symmetric matrices. V, D = eig (A, B) computes a diagonal matrix D of eigenvalues and a full matrix V whose columns are the corresponding eigenvectors as that A*V = B*V*D. If A is a real matrix and symmetric, the eigenvalues and the eigenvectors are real. If A is a real matrix and not symmetric, the eigenvalues and eigenvectors are complex. If A is a complex matrix symmetric, the eigenvalues are real but the eigenvectors are complex. If A is a complex matrix not symmetric, the eigenvalues and the eigenvectors are complex. The eig function uses LAPACK functions (dsyev, zheev, dgeevx, zgeevx, dsygv, zhegv, dggev, zggev). |
|
See Also: |