tags:

views:

44

answers:

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.

+2  A: 

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

related questions