Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
I get this error "Subscript indices must either be real positive integers or logicals."
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the following loop. It runs fine when r=1, but it gives me the following error when r=2 "Subscript indices must either be real positive integers or logicals."
for r=1:m
H_MMSE(:,r) = H_MMSE(RxP(:,r),TxP(:,r),N,pilotFrequency,h,SNR);
end
댓글 수: 1
답변 (3개)
the cyclist
2015년 11월 28일
The proximate cause is most likely that RxP(:,r) and/or TxP(:,r) are returning non-integer values, so you are trying to index into the array H_MMSE at a non-existent location.
A larger issue is that it looks like you may have defined H_MMSE as both a function and as an array variable. You shouldn't do that. Try renaming one of them.
댓글 수: 0
Image Analyst
2015년 11월 28일
See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F and you'll discover the reason why you're getting this error message.
댓글 수: 0
Walter Roberson
2015년 11월 29일
H_MMSE is a function before this starts. The function is invoked on the first iteration, and then the array H_MMSE is assigned to because it is the name that appears on the left hand side. So at iteration 2, H_MMSE is no longer a function and is instead now a array and you to access the array with parameters that belong to a function.
Change the name that you are assigning the value to.
for r=1:m
H_MMSE_vals(:,r) = H_MMSE(RxP(:,r),TxP(:,r),N,pilotFrequency,h,SNR);
end
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!