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 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