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?
0 件のコメント
回答 (1 件)
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
2013 年 1 月 8 日
Try this instead, to find zeros or negatives:
badIndexes = find(handles.PointLocs(:)<1) % no semicolon
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!