From: dpb on
Ben Williams wrote:
> ehi runa, are you joking? i know how to sort a vector, but if i sort
> the eigenvalues vector i loose the correspondencewith the
> eigenvectors matrix.
>
> so, does someone knows a solution?

doc sort % observe optional return values carefully

--
From: Ben Williams on
I read carefully doc sort but, as you know, if I sort the eigenvalues vector, I need also a trasformation on the eigenvector matrix.
I can't find in documentation a description about how to do this transformation. I'm not an expert in algebra.
So, If someones would like to give me a real help, I'll be very grateful to him!


dpb <none(a)non.net> wrote in message <h9o7g5$qbh$3(a)news.eternal-september.org>...
> Ben Williams wrote:
> > ehi runa, are you joking? i know how to sort a vector, but if i sort
> > the eigenvalues vector i loose the correspondencewith the
> > eigenvectors matrix.
> >
> > so, does someone knows a solution?
>
> doc sort % observe optional return values carefully
>
> --
From: Bruno Luong on
"Ben Williams" <supern3t(a)gmail.com> wrote in message <h9o7vm$407$1(a)fred.mathworks.com>...
>. I'm not an expert in algebra.

Ahhh, that's root problem.

[V D] = eig(A).

The eigen vectors are the columns of V. The eigen values are diagonal of D.

If you apply the SAME permutation of the columns of V and the diagonal of D, then everything is still consistent.

Now you have all pieces of information. Time to go back to the keyboard and plug the SORT command in the code.

Bruno
From: Steven Lord on

"Ben Williams" <supern3t(a)gmail.com> wrote in message
news:h9o7vm$407$1(a)fred.mathworks.com...
>I read carefully doc sort but, as you know, if I sort the eigenvalues
>vector, I need also a trasformation on the eigenvector matrix.
> I can't find in documentation a description about how to do this
> transformation. I'm not an expert in algebra.
> So, If someones would like to give me a real help, I'll be very grateful
> to him!

Look at the second output of SORT.

x = randperm(10)
z = x.^2
[y, ind] = sort(x)
[y; z(ind)]

Can you see how to apply a slight generalization of this technique to the
two outputs from EIG, possibly with a call to DIAG thrown into the mix?

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Greg on
On Sep 27, 12:31 pm, "Ben Williams" <super...(a)gmail.com> wrote:
> Hi everybody,
> I'm trying to calculate eigenvalues and relative eigenvectors in decreasing order?
>
> I've used [V,D] = EIG(X) command, but the order is different from what I need.
>
> For example, if I type>> [A,B] = eig([2 0 0; 0 1 0; 0 0 7])
>
> it assigns
>
> A =
>
>      0     1     0
>      1     0     0
>      0     0     1
>
> B =
>
>      1     0     0
>      0     2     0
>      0     0     7
>
> but I wanted 7 -> 2 -> 1 order!
>
> Any suggestions?

clc

M = ([2 0 0; 0 1 0; 0 0 7])

[E0 L0] = eig(M)
E1 = fliplr(E0)
L1 = flipud(fliplr(L0))

%or

[E2 L2] = eigs(M)

Hope this helps.

Greg