Question

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?

Was it helpful?

Solution

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));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top