How to use interp2 in MATLAB

2.1k Views Asked by At

I have some nodes in two dimensional, where $x,y$ are coordinates of them. Also, the value of $v$ is known in each node. Now it is necessary for me to have value of $v$ in some other nodes like $xq,yq$. To do this I used the following:

vq=interp2(x,y,v,xq,yq),

But there is an error:

The grid vectors must contain unique points.

some of the $xq,yq$ are the same with some $x,y$. Is this the problem for such error? Also, I need a higher order interpolant, what is the best method with reasonable cost for interpolation?

for example, in the simplest case

[x,y]=meshgrid(0:0.2:1,0:0.2:1);
 x=x(:);y=y(:);

 v=x.^2+y;

 xq=0.5;yq=0.5;
vq=interp2(x,y,v,xq,yq)