user3292186
user3292186

Reputation:

Get the eigen vector correspoinding to the ith largest eigen value

I have tried this code for my assignments, but I am getting error of type

??? Subscript indices must either be real positive integers or logicals.

This is my code:

for i = 5:200
    eigvecm = eigvecm(:, end:-1:end-(int8(i)-1));
end

Please point me out how to get this done?

Upvotes: 0

Views: 153

Answers (1)

Dan
Dan

Reputation: 45752

It sounds very much like end-(int8(i)-1) ends up reaching zero or below. Check what is the value of i when you get the error and compare this to how many columns eigvecm has.

BTW if you want the eigen vecotr corresponding to the ith largest eigen value how about this:

[vec, val] = eig(M);
[~, ind] = sort(diag(val), 'descend');

ind(i) is the column number for the ith largest eigen value. So to find the corresponding eigen vector:

vec_i = vec(:, ind(i));

Upvotes: 1

Related Questions