To calculate the eigenvalues of a matrix in MATLAB, you can use the eig()
function. The eig()
function returns a column vector containing the eigenvalues of the input matrix.
Here's an example usage:
main.m105 chars6 lines
In this example, the matrix A
is defined as a 3x3 matrix. The eig()
function is then used to calculate the eigenvalues of A
, which are stored in the eigenvalues
column vector.
Note that the eigenvalues are returned as complex numbers if the matrix is not Hermitian or symmetric.
You can also use the eigenvector and eigenvalue pair output of the eig()
function by using two output arguments:
main.m67 chars3 lines
In this case, V
is a matrix whose columns are the eigenvectors of A
, and D
is a diagonal matrix containing the eigenvalues of A
.
Hope this helps!
gistlibby LogSnag