문제

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?

도움이 되었습니까?

해결책

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));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top