How to make FOR loop for this following program.

4 ビュー (過去 30 日間)
Xuan Hiep Dinh
Xuan Hiep Dinh 2017 年 3 月 7 日
編集済み: Walter Roberson 2017 年 3 月 8 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by