Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I am geting the "Subscript indices must either be real positive integers or logicals." error but I think that my subscript indices are real positive integers?

조회 수: 1 (최근 30일)
The line of code is
handles.PointLocs = uint32(BWloc);
% gets the time where the point is collected
handles.timeBW = handles.TIME(handles.PointLocs);
BWloc is a 855x1 double, and handles.TIME is a 28908x1 double. After being converted to uint32 handles.PointLocs is made up of numbers that are integers, real, and possitive. Thus I don't know why I am still getting the error
Subscript indices must either be real positive integers or logicals.
What am I missing?

답변 (1개)

Matt J
Matt J 2013년 1월 8일
편집: Matt J 2013년 1월 8일
After being converted to uint32 handles.PointLocs is made up of numbers that are integers, real, and possitive.
The command
any(handles.PointLocs(:)<1)
can be used to check if you're right about that.
  댓글 수: 4
Image Analyst
Image Analyst 2013년 1월 8일
Try this instead, to find zeros or negatives:
badIndexes = find(handles.PointLocs(:)<1) % no semicolon
Matt J
Matt J 2013년 1월 9일
편집: Matt J 2013년 1월 9일
If I understand the what the equation does it just tell you that handles.PointLocs is not the same as a set that contains all the values from 1 to it's maximum value?
SETDIFF removes all values in the set 1:max from PointLocs and tells you whatever is left over. There should be nothing left over if your indexing is good because the only legitimate indices are the ones belonging to 1:max.
So, both tests I've proposed confirm that you have bad index values. In particular the first test confirms that some of them are zeros. Possibly you're doing 0-based indexing by mistake, forgetting that this is MATLAB abd not C\C++, and need to add +1 to convert them to 1-based indices.

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by