Info
This question is closed. Reopen it to edit or answer.
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?
    4 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (1)
  Matt J
      
      
 on 8 Jan 2013
        
      Edited: Matt J
      
      
 on 8 Jan 2013
  
      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 Comments
  Image Analyst
      
      
 on 8 Jan 2013
				Try this instead, to find zeros or negatives:
badIndexes = find(handles.PointLocs(:)<1) % no semicolon
  Matt J
      
      
 on 9 Jan 2013
				
      Edited: Matt J
      
      
 on 9 Jan 2013
  
			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.
This question is closed.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!