How to make FOR loop for this following program.

4 Ansichten (letzte 30 Tage)
Xuan Hiep Dinh
Xuan Hiep Dinh am 7 Mär. 2017
Bearbeitet: Walter Roberson am 8 Mär. 2017
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

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 7 Mär. 2017
Bearbeitet: Andrei Bobrov am 7 Mär. 2017
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 Kommentar
Xuan Hiep Dinh
Xuan Hiep Dinh am 7 Mär. 2017
Bearbeitet: Xuan Hiep Dinh am 7 Mär. 2017
This is the experimental data. So the plot should agree with it. However, I still cannot make it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by