1

What does the error "Subscript indices must either be real positive integers or logicals" means when using interp2. X,Y,Z,XI,YI are all vectors of the same length.

Brian
  • 26,662
  • 52
  • 135
  • 170
  • Also see [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the generic solution to this problem](http://stackoverflow.com/a/20054048/983722). – Dennis Jaheruddin Nov 27 '13 at 15:41

1 Answers1

4

It means that you trying to access an element in an array by using index as number with decimal point or a negative number, or maybe even using a string that looks like a number e.g. "2".

The only way to access the elements is by using positive integer OR logical (0 or 1).

array = [1 2 3 4 5 6];
array(4)    # returns 4th element of the array, 4.
mask = array > 3; # creates a mask of 0's and 1's (logicals).
array(mask) # return elements greater than 3, 4 5 6.

BUT you can't do:

array(2.0)

Or anything else other than positive integer or logical.

Alex

Alex
  • 1,315
  • 4
  • 16
  • 29