limit range of loop iteration
7 views (last 30 days)
Show older comments
Aamna Alshehhi
on 3 Oct 2019
Commented: Jess Lovering
on 3 Oct 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 Comments
David Hill
on 3 Oct 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.
Accepted Answer
Jess Lovering
on 3 Oct 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 Comments
More Answers (1)
Aamna Alshehhi
on 3 Oct 2019
2 Comments
Jess Lovering
on 3 Oct 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.
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!