Sorry, I missed the

```
w_1=eig(W_1);
w_2=eig(W_2);
```

To the number of digits you have shown, `W_1`

and `W_2`

are both rank one matrices, i.e., psd or hsd with only one positive eigenvalue. Are they supposed to be rank one matrices?

Eigenvectors are returned in the optional 2nd output argument of `eig`

.

The principal eigenvector is the column of the 2nd output argument corresponding to the largest eigenvalue.

help eig

eig Eigenvalues and eigenvectors.

E = eig(A) produces a column vector E containing the eigenvalues of

a square matrix A.

```
[V,D] = eig(A) produces a diagonal matrix D of eigenvalues and
a full matrix V whose columns are the corresponding eigenvectors
so that A*V = V*D.
[V,D,W] = eig(A) also produces a full matrix W whose columns are the
corresponding left eigenvectors so that W'*A = D*W'.
[...] = eig(A,'nobalance') performs the computation with balancing
disabled, which sometimes gives more accurate results for certain
problems with unusual scaling. If A is symmetric, eig(A,'nobalance')
is ignored since A is already balanced.
[...] = eig(A,'balance') is the same as eig(A).
E = eig(A,B) produces a column vector E containing the generalized
eigenvalues of square matrices A and B.
[V,D] = eig(A,B) produces a diagonal matrix D of generalized
eigenvalues and a full matrix V whose columns are the corresponding
eigenvectors so that A*V = B*V*D.
[V,D,W] = eig(A,B) also produces a full matrix W whose columns are the
corresponding left eigenvectors so that W'*A = D*W'*B.
[...] = eig(A,B,'chol') is the same as eig(A,B) for symmetric A and
symmetric positive definite B. It computes the generalized eigenvalues
of A and B using the Cholesky factorization of B.
[...] = eig(A,B,'qz') ignores the symmetry of A and B and uses the QZ
algorithm. In general, the two algorithms return the same result,
however using the QZ algorithm may be more stable for certain problems.
The flag is ignored when A or B are not symmetric.
[...] = eig(...,'vector') returns eigenvalues in a column vector
instead of a diagonal matrix.
[...] = eig(...,'matrix') returns eigenvalues in a diagonal matrix
instead of a column vector.
```