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

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

  1. This makes a lot of sense to me:
    ans =


    This makes no sense to me:
    ans =


    What am I doing wrong? Why doesn't the second interp2 return ~2?
    Brandon Sutherland, Jan 27, 2011
    1. Advertisements

  2. Brandon Sutherland

    Bruno Luong Guest

    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 Luong, Jan 27, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.