MATLAB: Using interp to plot

3d plotsinterpmeshgridplotsurf

I have the following plot:
Nx=5; % let it be an odd number for symmetry
Ny=5;
Nx1=Nx-1;
Ny1=Ny-1;
R= 5; %peak1
L=-5; %peak2
d=2; % distance between the two peaks
l=2; % length of each peak
V=zeros(Nx,Ny);
V((Nx1/2)-1,((Ny1/2)+1-(l/2)):((Ny1/2)+1+(l/2)))=R;
V((Nx1/2)-1+d,((Ny1/2)+1-(l/2)):((Ny1/2)+1+(l/2)))=L;
V=V';
x=linspace(0,25,25);
y=linspace(0,25,25);
h = meshgrid(V);
surf(x,y,h);
Since it is not defined as an exponential function, Is it possible to use interp to have a smooth surf plot (that makes it look less rectangular)?

Best Answer

interp2
should do what you want.