# interp2 is a hypocrite (or more likely: I'm misuing it)

Discussion in 'MATLAB' started by Brandon Sutherland, Jan 27, 2011.

1. ### Brandon SutherlandGuest

This makes a lot of sense to me:
ans =

1.0300

This makes no sense to me:
ans =

2.9900

What am I doing wrong? Why doesn't the second interp2 return ~2?

Brandon Sutherland, Jan 27, 2011

2. ### Bruno LuongGuest

Why it does? The second dimension of z corresponds to x = (1,2), the first dimension corresponds to y = (1,2), thus z(y,x) data provides is

z(1,1) = 1
z(1,2) = 2
z(2,1) = 3
z(2,3) = 4;

Now you provide xi ~ 1, yi ~ 2, so z(yi,xi) ~ z(2,1) = 3.

Matlab is correct (as almost always).

Bruno

Bruno Luong, Jan 27, 2011