limit range of loop iteration
조회 수: 7 (최근 30일)
이전 댓글 표시
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
David Hill
2019년 10월 3일
It would be nice to see the variables in a .mat file. It is hard to understand what you are trying to do here.
채택된 답변
Jess Lovering
2019년 10월 3일
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
추가 답변 (1개)
Aamna Alshehhi
2019년 10월 3일
댓글 수: 2
Jess Lovering
2019년 10월 3일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!