I'm trying to use interp2 where my five inputs are all 1 by n vectors. Is this possible? or do I need to enter them in mesh format?
Asked
Active
Viewed 1,769 times
1 Answers
1
No, you need to use meshgrid to generate your two first input arguments (X,Y), just like in this example (provided in Matlab's documentation):
[X,Y] = meshgrid(-3:.25:3);
Z = peaks(X,Y);
[XI,YI] = meshgrid(-3:.125:3);
ZI = interp2(X,Y,Z,XI,YI);
mesh(X,Y,Z), hold, mesh(XI,YI,ZI+15)
hold off
axis([-3 3 -3 3 -5 20])
I hope it helps.

Greg
- 6,038
- 4
- 22
- 37