I use a function at Matlab:
[V,D] = eig(C);
I see that V and D are always sorted ascending order. Does it always like that or should I sort them after I get V
and D
values?
If you want to guarantee sorted-ascending values, just do an extra
if ~issorted(diag(D))
[V,D] = eig(A);
[D,I] = sort(diag(D));
V = V(:, I);
end
to sort them the way you want.
Alternatively, use eigs
:
[V,D] = eigs(A,size(A,1)-1)