limit range of loop iteration
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aamna Alshehhi
am 3 Okt. 2019
Kommentiert: Jess Lovering
am 3 Okt. 2019
I got this code to plot Th2 vs Th3 and Th4 but I wanna limit the range of Th2 which is " i " to (0 to 47) and (313 to 360).
also I wanna get path coordinates of point P to same range.
any suggetions?
for i=0:47;
d =3.5; a = 4;b = 2; c = 1;
Th1= 0;
Z = d*exp(1i*deg2rad(Th1))- a*exp(1i*deg2rad(i));
Zc = conj(Z);
Ka = c*Zc; Kb = Z*Zc + c^2 -b^2; Kc = c*Z;
T = roots([ Ka Kb Kc]);
S = (c*T+Z)/b;
Th3(:,i+1) = rad2deg(angle(S));
Th4 (:,i+1) = rad2deg(angle(T));
P= a*exp(1i* deg2rad(Th2))+ 6*exp(1i* deg2rad(Th3-20));
end
Th2 = 0:47;
figure(1)
plot (Th2,Th3(1,:));
hold on;
plot (Th2,Th3(2,:));
xlabel ('TH)')
ylabel ('TH3')
figure(2)
plot (Th2,Th4(1,:));
hold on;
plot (Th2,Th4(2,:));
xlabel ('TH2') ;
ylabel ('TH4') ;
2 Kommentare
David Hill
am 3 Okt. 2019
It would be nice to see the variables in a .mat file. It is hard to understand what you are trying to do here.
Akzeptierte Antwort
Jess Lovering
am 3 Okt. 2019
Do you mean that you want your loop to go through i = 0 to 47 and then 313 to 360? If that is what you want then you can just replace the line:
for i=0:47;
with
for i=[0:47 313:360];
Is that your goal? If not, maybe you can provide some more detail. Thanks.
0 Kommentare
Weitere Antworten (1)
Aamna Alshehhi
am 3 Okt. 2019
2 Kommentare
Jess Lovering
am 3 Okt. 2019
It is difficult to help since we don't have the Th2 variable. Plus, it looks like it is redefined after the loop to be 0:47 so then it is shorter than the variable Th3 that is generated in the loop. You could also define it as Th2 = 0:360 to make it the same size, but I think that may not be what you are trying to view.
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!