필터 지우기
필터 지우기

Subscript indices must either be real positive integers or logicals.

조회 수: 1 (최근 30일)
jeffin
jeffin 2014년 9월 22일
답변: Adam 2014년 9월 22일
Hi,
I get this error ,
Subscript indices must either be real positive integers or logicals. The line with this error is,
Error in motionComp (line 34)
imageComp(i:i+mbSize-1,j:j+mbSize-1) =
imgI(refBlkVer:refBlkVer+mbSize-1,refBlkHor:refBlkHor+mbSize-1);
Please help me in resolving this error and thanks in advance.

채택된 답변

Adam
Adam 2014년 9월 22일
If your values to be used as indices into an array are the result of some calculation, especially one which uses division, multiplication and really anything more complex than addition and subtraction you should use:
idx = round(idx);
for an index value, idx, or just put round(idx) straight into the indexing line if you prefer.
If you are confident you should never get floating point-based index inaccuracies then you can, of course, leave that off, but if you cannot be sure of every conceivable output of your function that creates idx then this is best to ensure a valid index value.

추가 답변 (1개)

Jos (10584)
Jos (10584) 2014년 9월 22일
Check the values of the indexing variables, for instance, using:
disp(i)
disp(refBlkVer)
It will probably show that they are NOT real positive integers.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by