Plot 3D figure

1 view (last 30 days)
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)

Accepted Answer

Walter Roberson
Walter Roberson on 11 Nov 2021
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 Comments
Walter Roberson
Walter Roberson on 12 Nov 2021
Looks good, but what do you do with phase after you calculate it?

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!