How to make FOR loop for this following program.

4 次查看(过去 30 天)
Dear colleagues. Please help me to check this following program. I need to plot function oscy1 and oscx1 depend on the variable theta. However, these functions depend both on time t and angle theta. So I need to make 2 FOR loops for these.
Range of theta : 0 to 360 degree.
Range of time t: 0 to 1000.
for i=1:72
theta(1)=0;
theta(i+1)= theta(i)+5; %angle for incident light
thetarad(i)= theta(i)*pi/180;
for m=1:1000
t(1) = 1;
t(m+1) = t(m)+1;
c = 3*10^8; % speed of light
lambda = 1.55*10^-6; % wavelength
omega = 2*pi*c/lambda; %angular frequency
%phase_t = omega*t;
nrx = 1.52761; %refractive index X
nry = 1.53596; %refractive index Y
L = pi*lambda/((nry-nrx)*2*pi); % Half wavelength Polarization LHWP
omegat(m) = 0.01*(t(m)-1)*pi;
oscy1(m) = exp(j*omegat(m))*sin(thetarad(i))*exp(j*2*pi*L*nry/lambda);
oscx1(m) = exp(j*omegat(m))*cos(thetarad(i))*exp(j*2*pi*L*nrx/lambda);
aa(m) = real(oscx1(m));
bb(m) = real(oscy1(m));
end
Qin(i)=theta(i);
Qaa(i)=aa(?);
Qbb(i)=bb(?);
end

采纳的回答

Andrei Bobrov
Andrei Bobrov 2017-3-7
编辑:Andrei Bobrov 2017-3-7
c = 3*10^8; % speed of light
lambda = 1.55*10^-6; % wavelength
omega = 2*pi*c/lambda; %angular frequency
nrx = 1.52761; %refractive index X
nry = 1.53596; %refractive index Y
L = pi*lambda/((nry-nrx)*2*pi); % Half wavelength Polarization LHWP
th = (0:5:360)*pi/180;
omt = 0.01*(0:99)'*pi;
e1 = exp(1i*2*pi*L/lambda);
aa = real(exp(1i*omt*sin(th))*e1^nry);
bb = real(exp(1i*omt*cos(th))*e1^nrx);
  1 个评论
Xuan Hiep Dinh
Xuan Hiep Dinh 2017-3-7
编辑:Xuan Hiep Dinh 2017-3-7
This is the experimental data. So the plot should agree with it. However, I still cannot make it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by