Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eigenvalues in MATLAB

In MATLAB, when I run the command [V,D] = eig(a) for a symmetric matrix, the largest eigenvalue (and its associated vector) is located in last column. However, when I run it with a non-symmetric matrix, the largest eigenvalue is in the first column.

I am trying to calculate eigenvector centrality which requires that I take the compute the eigenvector associated with the largest eigenvalue. So the fact that the largest eigenvalue appears in two separate places it makes it difficult for me to find the solution.

like image 927
Spencer Avatar asked Jul 20 '10 15:07

Spencer


1 Answers

What I usually do is:

[V D] = eig(a);
[D order] = sort(diag(D),'descend');  %# sort eigenvalues in descending order
V = V(:,order);
like image 108
Amro Avatar answered Sep 28 '22 02:09

Amro