# Ordering of Eigenvalues and Eigenvectors in MATLAB

The following MATLAB function produces the Eigenvalues and Eigenvectors of matrix X.

[V,D] = eig(X) produces a diagonal matrix D of eigenvalues and a
full matrix V whose columns are the corresponding eigenvectors so
that X*V = V*D.


My questions are:

1. Does this mean that the first (or principal or dominant) eigenvector lay on the last column of V? NOTE: the author says that, all the coefficients of the dominant eigenvector are positive and that the remaining eigenvectors (the rest of columns) must have components that are negative, in order to be orthogonal (what does this mean) to u^(i);
2. Regarding the "corresponding eigenvecrtors", do we read them "column-by-column" OR "row-by-row"?
3. Do eigenvalues-eigenvectors come in pairs? If yes, and considering the above, then does the corresponding eigenvalue lay on the bottom-right of matrix D?
4. Actually, I want eigenvalues and their corresponding eigenectors in decreasing order, and then select the, 2 say, "most significant" ones. What I should do?
5. Out of curiosity, but what does it mean "the two times-series Fi and Fi' are uncorrelated in the sense that their empirical correlation vanishes for i != i' ??? How to check that in MATLAB?

LOTS of questions, I know, but I would REALLY appreciate if you could help me answer some of them!

-
 Concerning the last question check this wiki article en.wikipedia.org/wiki/Cross-correlation – Paul Jul 15 '12 at 16:41 The help blurb you quote states that the eigenvectors are columns of V. – David Ketcheson Jul 16 '12 at 10:19

## migrated from stats.stackexchange.comJul 15 '12 at 19:27

Actually each diagonal element (i,i) of matrix D (i.e. eigenvalue) corresponds to ith column of matrix V. That is the the higher value of D(i,i) the more important the corresponding eigenvector.

MatLab function eig(X) sorts eigenvalues in the acsending order, so you need to take the last two colmns of matrix V

Also do remember that if you try to perform factor analysis you can simply use MatLab's princomp function or center the data before using eig.

The signs of components for the first eigenvector is not defines anyhow (in case X is nonsingular and symmetric, e.g. correlation matrix as in factor analysis)

-
 Could you please explain more detailed the "...or center the data before using" and the other one which is about "the signs of components"... – eualin Jul 15 '12 at 16:45 He means subtracting out the mean of each column. Also, svd, princomp, and eigs (which can be used to just take the 2 largest) all sort in descending order. So make sure to pay attention to which you're using. – John Jul 15 '12 at 16:48

At least in the older versions of Matlab, eig didn't sort the eigenvalues. (For complex eigenvalues there is not even a natural ordering.)

Thus it is safer to pick the wanted eigenvalue indices $i$ by inspecting all eigenvalues, and get the corresponding eigenvectors as the columns $V(:,i)$.

-

Given the formula, you should read the vectors column-by-column.

The value associated with the i-th vector is the i-th value on the diagonal of D.

I am not sure the eigenvalues or egenvectors are ordered, and the "order" you are talking about doesn't seem clear to me...

If I assume you want to order the vectors by decreasing eigenvalues, then simply switch the right columns in V and the right rows and columns in D.

-