Plot 3D figure

2 ビュー (過去 30 日間)
Tina Hsiao
Tina Hsiao 2021 年 11 月 11 日
コメント済み: Walter Roberson 2021 年 11 月 12 日
Hello, I would like to plot this fugure (ro, Z, I), my code as below, could you please give me a help? Thanks a lot.
clear all; close all; clc
for n = 1:1:100
i = sqrt(-1);
a = 0.62;
NA = 0.29;
wL = 772e-3; % micro meter
R = linspace (-0.4,0.4,100);
ro = ((2*pi)/wL)*NA.*R;
Z = linspace(-1,1,100);
mu = ((2*pi)/wL)*NA^2*Z;
fun1 = @(r)r.*exp(-r.^2).* besselj(ro(n),r) .*exp(-(1.*i.*mu(n).*r.^2)./2);
q1 = integral(fun1,0,1);
q2 = integral(fun1,0,a);
E(n) = (2/(1-exp(-1)))*q1- 2*(2/(1-exp(-1)))*q2; % electric field
I(n) = abs(E(n)).^2; % intensity
end
figure(2)
plot(R, I)

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 11 日
The scale factor between and Z or R values is not obvious. It is also not obvious why you used the ranges you did: the sample plot suggests that they should be reversed. However, I had to use those ranges to get any plot of note -- and you can see it is not the expected plot. The output was essentially unchanged with Z -- which suggests that possibly Z is the wrong scale.
a = 0.62;
NA = 0.29;
wL = 772e-3; % micro meter
num_R = 100;
num_Z = 101;
Zvals = linspace(-5,5,num_Z)/1e2;
Rvals = linspace(-40,40,num_R)/1e2;
for Ridx = 1 : num_R
R = Rvals(Ridx);
ro = ((2*pi)/wL)*NA.*R;
for Zidx = 1 : num_Z
Z = Zvals(Zidx);
mu = ((2*pi)/wL)*NA^2*Z;
fun1 = @(r)r .* exp(-r.^2) .* besselj(ro,r) .* exp(-(1.*i.*mu.*r.^2)./2);
q1 = integral(fun1,0,1);
q2 = integral(fun1,0,a);
E(Ridx, Zidx) = (2/(1-exp(-1)))*q1 - 2*(2/(1-exp(-1)))*q2; % electric field
end
end
I = abs(E).^2; % intensity
figure(2)
surf(Zvals, Rvals, I, 'edgecolor', 'none')
  2 件のコメント
Tina Hsiao
Tina Hsiao 2021 年 11 月 12 日
Thanks a lot. It works.
clear all; close all; clc
NA = 0.29;
wL = 772e-3; % micro meter
num_Z = 100;
num_R = 100;
Zvals= linspace(-40,40,num_Z);
Rvals = linspace(-5,5,num_R);
for Zidx = 1 : num_Z
Z = (Zvals(Zidx));
mu = ((2*pi)/wL).*NA^2.*Z;
for Ridx = 1 : num_R
R = (Rvals(Ridx));
ro = ((2*pi)/wL)*NA.*R;
fun1 = @(r)r.* exp(-r.^2) .* besselj(0,ro*r).* exp(-(1.*i.*mu.*r.^2)./2);
fun2 = @(a)a.* exp(-a.^2) .* besselj(0,ro*a).* exp(-(1.*i.*mu.*a.^2)./2);
q1 = integral(fun1,0,1);
q2 = integral(fun2,0,0.62);
E(Ridx, Zidx) = (2/(1-exp(-1))).*q1 - 2*(2/(1-exp(-1))).*q2; % electric field
end
end
phase = atan2(imag(E),real(E));
I = abs(E).^2; % intensity
figure(2)
surf( Rvals, Zvals, I/max(max(I)), 'edgecolor', 'none')
Walter Roberson
Walter Roberson 2021 年 11 月 12 日
Looks good, but what do you do with phase after you calculate it?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by