matlab 声明变量范围,matlab中syms如何定义变量范围

时间:2024-10-22 08:28:50

符号运算太慢!

把表达式写出来有太占地方!不过运行快啊!

>> zhouch

ans =

76.4040

>>

function zhouch

quad(@zhchjf,0,2*pi/5)

function y=zhchjf(theta)

z1=6;

z2=z1-1;

R=48.78;

r=8.13;

Q=R-r;

e=7.05;

k=12.6;

f=r/e;

a=sin(z1*theta);

b=f+cos(z1*theta);

m=atan(a./b);

p=m-theta;       %theta

c=sin(theta+p);

n=asin(f*c);

o=n-p;          %phi

g=(z1/z2)*o;    %psi

x2t=Q*sin(theta)+e*sin(z2*theta)-k*sin(p);       %原始齿形

y2t=Q*cos(theta)-e*cos(z2*theta)+k*cos(p);

x3t=x2t.*cos(o-g)-y2t.*sin(o-g)-e*sin(g);        %共轭齿形

y3t=x2t.*sin(o-g)+y2t.*cos(o-g)-e*cos(g);

ds2=(((813./20.*cos(theta)+141./4.*cos(5.*theta)-63./5.*cos(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta).*((6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1)).*cos(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta)-(813./20.*sin(theta)+141./20.*sin(5.*theta)-63./5.*sin(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta)).*sin(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta).*(-47.*(1626./235.*cos(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)+1626./235.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)-271./470.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(3./2).*(12.*sin(6.*theta)./(271./235+cos(6.*theta)).^2.*cos(6.*theta)+12.*sin(6.*theta).^3./(271./235+cos(6.*theta)).^3))./(55225-73441.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)).^(1./2)+1./5.*(6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1./5)-(-813./20.*sin(theta)+141./4.*sin(5.*theta)-63./5.*sin(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta).*((6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1)).*sin(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta)-(813./20.*cos(theta)-141./20.*cos(5.*theta)+63./5.*cos(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta)).*cos(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta).*(-47.*(1626./235.*cos(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)+1626./235.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)-271./470.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(3./2).*(12.*sin(6.*theta)./(271./235+cos(6.*theta)).^2.*cos(6.*theta)+12.*sin(6.*theta).^3./(271./235+cos(6.*theta)).^3))./(55225-73441.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)).^(1./2)+1./5.*(6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1./5)-141./20.*cos(6./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))-6./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))+6./5.*theta).*(282.*(1626./235.*cos(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)+1626./235.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)-271./470.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(3./2).*(12.*sin(6.*theta)./(271./235+cos(6.*theta)).^2.*cos(6.*theta)+12.*sin(6.*theta).^3./(271./235+cos(6.*theta)).^3))./(55225-73441.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)).^(1./2)-6./5.*(6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)+6./5)).^2+((813./20.*cos(theta)+141./4.*cos(5.*theta)-63./5.*cos(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta).*((6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1)).*sin(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta)+(813./20.*sin(theta)+141./20.*sin(5.*theta)-63./5.*sin(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta)).*cos(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta).*(-47.*(1626./235.*cos(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)+1626./235.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)-271./470.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(3./2).*(12.*sin(6.*theta)./(271./235+cos(6.*theta)).^2.*cos(6.*theta)+12.*sin(6.*theta).^3./(271./235+cos(6.*theta)).^3))./(55225-73441.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)).^(1./2)+1./5.*(6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1./5)+(-813./20.*sin(theta)+141./4.*sin(5.*theta)-63./5.*sin(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta).*((6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1)).*cos(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta)-(813./20.*cos(theta)-141./20.*cos(5.*theta)+63./5.*cos(atan(sin(6.*theta)./(271./235+cos(6.*theta)))-theta)).*sin(-1./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))+1./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))-1./5.*theta).*(-47.*(1626./235.*cos(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)+1626./235.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)-271./470.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(3./2).*(12.*sin(6.*theta)./(271./235+cos(6.*theta)).^2.*cos(6.*theta)+12.*sin(6.*theta).^3./(271./235+cos(6.*theta)).^3))./(55225-73441.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)).^(1./2)+1./5.*(6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)-1./5)+141./20.*sin(6./5.*asin(271./235.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2))-6./5.*atan(sin(6.*theta)./(271./235+cos(6.*theta)))+6./5.*theta).*(282.*(1626./235.*cos(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)+1626./235.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(1./2)-271./470.*sin(6.*theta)./(271./235+cos(6.*theta))./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2).^(3./2).*(12.*sin(6.*theta)./(271./235+cos(6.*theta)).^2.*cos(6.*theta)+12.*sin(6.*theta).^3./(271./235+cos(6.*theta)).^3))./(55225-73441.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)).^(1./2)-6./5.*(6.*cos(6.*theta)./(271./235+cos(6.*theta))+6.*sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)./(1+sin(6.*theta).^2./(271./235+cos(6.*theta)).^2)+6./5)).^2).^(1./2);

y=ds2;