我运行的是一个循环体,每循环一次都要对几个符号变量清零:
for i=3:69
syms u2 v2 w2
k1=(cx(i-1)-cx(i-2))/q;
k2=(cx(i)-cx(i-1))/q;
X=[fy1(i+927),fy1(i+928),fy1(i+929)];
Y=[k1,cx(i-2),cx(i-1),cx(i),k2];
pp=spline(X,Y);
der_pp=fnder(pp);
der_pp1=fnder(der_pp);
cx_fy1=fnval(der_pp,fy1(i+929));
cx_fy11=fnval(der_pp1,fy1(i+929));
%y轴
k1=(cy(i-1)-cy(i-2))/q;
k2=(cy(i)-cy(i-1))/q;
X=[fy1(i+927),fy1(i+928),fy1(i+929)];
Y=[k1,cy(i-2),cy(i-1),cy(i),k2];
pp=spline(X,Y);
der_pp=fnder(pp);
der_pp1=fnder(der_pp);
cy_fy1=fnval(der_pp,fy1(i+929));
cy_fy11=fnval(der_pp1,fy1(i+929));
%z轴
k1=(cz(i-1)-cz(i-2))/q;
k2=(cz(i)-cz(i-1))/q;
X=[fy1(i+927),fy1(i+928),fy1(i+929)];
Y=[k1,cz(i-2),cz(i-1),cz(i),k2];
pp=spline(X,Y);
der_pp=fnder(pp);
der_pp1=fnder(der_pp);
cz_fy1=fnval(der_pp,fy1(i+929));
cz_fy11=fnval(der_pp1,fy1(i+929));
bbx=cy_fy1*cz_fy11-cz_fy1*cy_fy11;
bby=cz_fy1*cx_fy11-cx_fy1*cz_fy11;
bbz=cx_fy1*cy_fy11-cy_fy1*cx_fy11;
ak=((cx_fy1^2+cy_fy1^2+cz_fy1^2))^(1/2);
%sv=solve('(u*cx_fy1+v*cy_fy1+w*cz_fy1)/ak=cos(kosy(i))','u*cx_fy11+v*cy_fy1+w*cz_fy1=0','u^2+v^2+w^2=1');
e=(u2*cx_fy1+v2*cy_fy1+w2*cz_fy1)./ak-cos(kosy(i));
f=u2*bbx+v2*bby+w2*bbz;
g=u2.^2+v2.^2+w2.^2-1;
[u2 v2 w2]=solve(e,f,g);
%y轴的与空间坐标系各轴间的夹角的余弦
k=((bby*w2(1)-bbz*v2(1))^2+(bbz*u2(1)-bbx*w2(1))^2+(bbx*v2(1)-bby*u2(1))^2)^(1/2);
cosx=(bby*w2(1)-bbz*v2(1))/k;
cosy=(bbz*u2(1)-bbx*w2(1))/k;
cosz=(bbx*v2(1)-bby*u2(1))/k;
%平面坐标向空间坐标的转化
kx=cx(i)+(bx(i+1)-bx(i))*u2(1)+(by(i+1)-by(i))*cosx;
ky=cy(i)+(bx(i+1)-bx(i))*v2(1)+(by(i+1)-by(i))*cosy;
kz=cz(i)+(bx(i+1)-bx(i))*w2(1)+(by(i+1)-by(i))*cosz;
%转向球面
cx(i+1)=eval(char(kx*R/(kx^2+ky^2+kz^2)^(1/2)));%????????????????????????????
cy(i+1)=eval(char(kx*R/(kx^2+ky^2+kz^2)^(1/2)));
cz(i+1)=eval(char(kx*R/(kx^2+ky^2+kz^2)^(1/2)));
end
我该如何对 u2 v2 w2 清零
如何在对某个符号变量清零