调用函数返回值进行比较 新手。
Mostrar comentarios más antiguos
程序:
syms x y;
theta=pi/3;
a=0.4; b=0.15; c=0.005;
k1=0;
k2=2*b-c;
if 0<theta<pi & theta~=pi/3
k1=(2*b-c)/tan(theta);
end
x1=-k1/2; y1=k2/2;
x2=k1/2; y2=-k2/2;
for i=1:400
syms R;
R(1)=x1;
d=0.001;
[Ap,Av]=second2(R(i),x1,x2,y1,y2,theta,a,b,k1,k2);
R(i+1)=R(i)+d;
i=i+1;
Ap=vpa(Ap);
Av=vpa(Av);
if Ap<=Av
break;
end
end
函数
function [Ap,Av]=second2(xt1,x1,x2,y1,y2,theta,a,b,k1,k2)
syms x y ;
yt1=-(xt1-x1)/tan(pi-theta)+y1;
syms E F;
[E,F]=solve(y-yt1==(x-xt1)*tan(pi-theta),x^2/a^2+y^2/b^2==1,x,y);
xt2=E(1);xt3=E(2);yt2=F(1);yt3=F(2);
syms temp;
if abs(xt1-xt2)>abs(xt1-xt3)
temp=xt2; xt2=xt3;xt3=temp;
end
if abs(yt1-yt2)>abs(yt1-yt3)
temp=yt2; yt2=yt3;yt3=temp;
end
AL=pi*a*b/2;
AL2=((yt1-y1)^2+(xt1-x1)^2)^(1/2)*(k1^2+k2^2)^(1/2);
Ap=abs(int((a^2-(a^2*y^2)/b^2)^(1/2)-((y-yt1)/tan(pi-theta)+xt1),x,yt2,yt3));
Av=AL2-AL+Ap;
end
错误信息
无法从 sym 转换为 logical。
出错 second (line 20)
if Ap<Av
不知道还哪里没有赋值 无法进行比较
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre 描述性统计量 en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!