高手帮忙看看是哪里的问题?
clc;<BR>clear;<BR>R=19880;<BR>a=25.6;<BR>th=2*asin(a/(2*R));<BR>fy=acos(0.5);<BR>for n=1:40<BR> X(n,1)=R*sin(n*th-th)*cos(0);<BR> X(n,n)=R*sin(n*th-th)*cos(fy);<BR> Y(n,1)=R*sin(n*th-th)*sin(0);<BR> Y(n,n)=R*sin(n*th-th)*sin(fy);<BR> Z(n,1)=R*cos(n*th-th)-R;<BR> Z(n,n)=R*cos(n*th-th)-R;<BR>end<BR>for n=3:40<BR> for m=2:n-1<BR> x1=X(n-1,m-1);<BR> x2=X(n-1,m);<BR> x3=X(n,m-1);<BR> y1=Y(n-1,m-1);<BR> y2=Y(n-1,m);<BR> y3=Y(n,m-1);<BR> z1=Z(n-1,m-1);<BR> z2=Z(n-1,m);<BR> z3=Z(n,m-1);<BR> fun='(((x1-x(1))^2+(z1-x(3))^2+(y1-x(2))^2)^(1/2)-25.6)^2+(((x2-x(1))^2+(z2-x(3))^2+(y2-x(2))^2)^(1/2)-25.6)^2+(((x3-x(1))^2+(z3-x(3))^2+(y3-x(2))^2)^(1/2)-25.6)^2'; %目标函数<BR> fun=subs(fun)<BR> fun=vpa(fun,6)<BR> x0=;<BR> options=foptions;<BR> options(3)=1e-6;<BR> A=[ ]; %线性不等式约束<BR> b=[ ];<BR> Aeq=[ ]; %无线性等式约束<BR> beq=[ ];<BR> lb=[ ]; %x没有下、上界<BR> ub=[ ];<BR> =fmincon(fun,x0,A,b,Aeq,beq,lb,ub,@mycon);<BR> X(n,m)=x(1,1);<BR> Y(n,m)=x(1,2);<BR> Z(n,m)=x(1,3);<BR> end<BR>end<BR><BR>约束条件:x(1)^2+x(2)^2+(x(3)+19880)^2-19880^2=0回复:(creast)高手帮忙看看是哪里的问题?
fun要写成function的形式<BR>具体你看帮助吧<BR><BR>doc fmincon
页:
[1]