How to draw multiple surface plots on the same mesh?

5 ビュー (過去 30 日間)
Muhamed Sewidan
Muhamed Sewidan 2020 年 10 月 9 日
コメント済み: Muhamed Sewidan 2020 年 10 月 14 日
I use this code to draw a Gaussian normal distribution. I want to plot several distributions at equal distance from the original one (like the figure).
How can I do so?
lambda = 1; % wavelength
E0 = 1; % max value of E-field amplitude
% ==================================================================
% prepare the coordinates mesh
% ----------------------------
zLin = linspace(-201,201,400) * lambda; % z-coordinate (horizontal)
rLin = linspace(-65,65,100) * lambda; % radius-coordinate (vertical)
[z,r] = meshgrid(zLin,rLin); % create mesh
% ===================================================================
wFactor = 4;
w0 = wFactor * lambda; % minimal waist
zR = pi* w0^2 / lambda; % Rayleigh length
w = w0 * sqrt( 1 + (z / zR) .^2 ); % Beam radius at any arbitrary distance (equ. 3)
% Irradiance
eta = 377; % for free space
I0 = abs(E0)^2/eta;
I = I0 .* (w0 ./ w).^2 .* exp( -2*(r./w).^2 );
surf(z,r,I); shading interp
  1 件のコメント
VBBV
VBBV 2020 年 10 月 9 日
編集済み: VBBV 2020 年 10 月 9 日
Use contourf function as
%if true
% code
% end
v2 = 0:0.00009:0.0025;
contourf(z,r,I,v2,'edgecolor','none');shading interp;

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

採用された回答

Durganshu
Durganshu 2020 年 10 月 9 日
編集済み: Durganshu 2020 年 10 月 9 日
Did you try hold on?
figure;
surf(z1,r1,I1);
hold on
zlin2= linspace(-101,101,300) * lambda; %whatever shifted values you want
rLin2 = linspace(-65,65,100) * lambda; %whatever shifted values you want
[z2,r2] = meshgrid(zLin2,rLin2);
% similarly define I2 and then plot
surf(z2,r2,I2);
  9 件のコメント
Durganshu
Durganshu 2020 年 10 月 14 日
編集済み: Durganshu 2020 年 10 月 14 日
Yes, that should work. Did you try it? All you're supposed to do is tweaking the I2 function in order to find the appropriate fit.
Muhamed Sewidan
Muhamed Sewidan 2020 年 10 月 14 日
Thank you I will try it out.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by