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)?

 採用された回答

Adam
Adam 2014 年 8 月 21 日

1 投票

interp2
should do what you want.

3 件のコメント

mick777
mick777 2014 年 8 月 21 日
Thank you for your reply. I am trying to implement it, but keep getting a weird plot. Could you please guide me on how to do this. This is what I got:
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);
[Xq,Yq] = meshgrid(-3:0.25:3);
Vq = interp2(x,y,h,Xq,Yq,'cubic');
surf(Xq,Yq,Vq);
Adam
Adam 2014 年 8 月 21 日
編集済み: Adam 2014 年 8 月 21 日
Do you really want your interpolated grid to run from -3 to 3 given that your original ran from 0 to 25?
Try:
[Xq,Yq] = meshgrid(0:0.25:25);
Vq = interp2(x,y,h,Xq,Yq )
instead
mick777
mick777 2014 年 8 月 22 日
It works. I understood where I went wrong. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

質問済み:

2014 年 8 月 21 日

コメント済み:

2014 年 8 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by