How to define multiple while loop conditions?
Show older comments
Hello
I have a basic script to calculate a curve length. In first step I eliminate the complex number with a while loop function. In second step I try to received a curve length with one more specific parameter(second angle). But second "while" function do not work. I can not realize this problem. Can you help me with this problem?
if true
% code
r1=0;
r2=110.5;
r3=212.5;
beta2d=35;
beta1dpoz=45;
format long
xs2=r3*sind(beta2d); ys2=r1-r3*cosd(beta2d);
kruh1=xs2^2+ys2^2; kruh2=r1^2+r3^2-2*r1*r3*cosd(beta2d);
xA1=1/2*(xs2*(1+((r1^2-r2^2)/(xs2^2+ys2^2)))+ys2*(sqrt(((2*(r1^2+r2^2))/(xs2^2+ys2^2))-((r1^2-r2^2)/(xs2^2+ys2^2))^2-1))); xA2=1/2*(xs2*(1+((r1^2-r2^2)/(xs2^2+ys2^2)))-ys2*(sqrt(((2*(r1^2+r2^2))/(xs2^2+ys2^2))-((r1^2-r2^2)/(xs2^2+ys2^2))^2-1)));
xAmat=[xA1,xA2]; xA=max(xAmat);
while isreal(xA)==0
r1=r1+0.1;
xs2=r3*sind(beta2d);
ys2=r1-r3*cosd(beta2d);
kruh1=xs2^2+ys2^2;
kruh2=r1^2+r3^2-2*r1*r3*cosd(beta2d);
xA1=1/2*(xs2*(1+((r1^2-r2^2)/(xs2^2+ys2^2)))+ys2*(sqrt(((2*(r1^2+r2^2))/(xs2^2+ys2^2))-((r1^2-r2^2)/(xs2^2+ys2^2))^2-1)));
xA2=1/2*(xs2*(1+((r1^2-r2^2)/(xs2^2+ys2^2)))-ys2*(sqrt(((2*(r1^2+r2^2))/(xs2^2+ys2^2))-((r1^2-r2^2)/(xs2^2+ys2^2))^2-1)));
xAmat=[xA1,xA2];
xA=max(xAmat);
end
p=sqrt(2*r1^2+r3^2-2*r1*r3*(sind(beta2d)+cosd(beta2d)));
if r2>p
yA1=sqrt(r1^2-xA^2);
yA=yA1;
else
yA=-1*sqrt(r1^2-xA^2);
end
gamma=pi/2-atan(yA/xA);
gammad=gamma*180/pi;
L=2*pi*r1*gammad/360;
b=abs(abs(xs2)-abs(xA));
a=abs(abs(ys2)-abs(yA));
gammad1=gammad-90;
etad=atand(b/a);
deltad=abs(180-90-etad);
beta1d=deltad-gammad1;
if beta1d>=beta1dpoz
beta1d=beta1d
else
r1=r1
while beta1d>=beta1dpoz
r1=r1+0.1
xs2=r3*sind(beta2d);
ys2=r1-r3*cosd(beta2d);
kruh1=xs2^2+ys2^2;
kruh2=r1^2+r3^2-2*r1*r3*cosd(beta2d);
xA1=1/2*(xs2*(1+((r1^2-r2^2)/(xs2^2+ys2^2)))+ys2*(sqrt(((2*(r1^2+r2^2))/(xs2^2+ys2^2))-((r1^2-r2^2)/(xs2^2+ys2^2))^2-1)));
xA2=1/2*(xs2*(1+((r1^2-r2^2)/(xs2^2+ys2^2)))-ys2*(sqrt(((2*(r1^2+r2^2))/(xs2^2+ys2^2))-((r1^2-r2^2)/(xs2^2+ys2^2))^2-1)));
xAmat=[xA1,xA2];
xA=max(xAmat);
p=sqrt(2*r1^2+r3^2-2*r1*r3*(sind(beta2d)+cosd(beta2d)));
if r2>p
yA1=sqrt(r1^2-xA^2);
yA1=yA;
else
yA=-1*sqrt(r1^2-xA^2);
end
gamma=pi/2-atan(yA/xA);
gammad=gamma*180/pi;
L=2*pi*r1*gammad/360;
b=abs(abs(xs2)-abs(xA));
a=abs(abs(ys2)-abs(yA));
gammad1=gammad-90;
etad=atand(b/a);
deltad=180-90-etad;
beta1d=deltad-gammad1;
end
end
q=[r1 r2 r3 beta1d beta2d L];
end
Accepted Answer
More Answers (0)
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!