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 个评论
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