To calculate the eigenvectors of a matrix in Matlab, you can use the eig
function. The syntax is as follows:
main.m16 chars2 lines
where A
is the square matrix for which you want to calculate the eigenvectors, D
is the diagonal matrix of eigenvalues, and V
is the matrix of eigenvectors. The columns of V
correspond to the eigenvectors of A
.
Here's an example:
main.m113 chars6 lines
In this example, A
is a 3x3 matrix, so V
is also a 3x3 matrix. The eigenvectors are stored in the columns of V
, so we extract them using the syntax V(:,1)
for eigenvector 1, V(:,2)
for eigenvector 2, and V(:,3)
for eigenvector 3.
gistlibby LogSnag