coldspring 发表于 2006-11-22 09:43

求助高手

clear all
syms z0 z1 x1 x2 y0 n
n=0;
z0=
f=x1^2+4*x2^2;
v=;
df=jacobian(f,v);
Q=jacobian(df,v);
g=-df;
eps1=1e-4;
eps2=1e-5;
f0=subs(f, {x1,x2},{z0(1,1),z0(1,2)});
g0=subs(g, {x1,x2},{z0(1,1),z0(1,2)});
h0=;
p0=-g0;
z1=z0-((g0*g0')/(g0*Q*g0'))*g0;
f1=subs(f, {x1,x2},{z1(1,1),z1(1,2)});
g1=subs(g, {x1,x2},{z1(1,1),z1(1,2)});
while(f1<0.1)
   
end
x1;
f1;
g1
运行后出现 ??? Function 'lt' is not defined for values of class 'sym'.
怎么解决!!!!!!!!

xjzuo 发表于 2006-11-22 10:00

回复

while(f1<0.1)
   
end

中间什么都没有,怎会不出错?

coldspring 发表于 2006-11-22 10:43

这个也是这样

function =lsliu(f,z0,h)
syms x1 x2 y1 y2 z1 z2
y0=subs(f,,z0);
%n=0
z2=z0+h;
y2=subs(f,,z2);
if(y2>=y0)
z1=z2;
y1=y2;
h=-h;
else
z1=z0;
y1=y0;
z0=z2;
y0=y2;
h=2*h;
end
z2=z0+h;
y2=subs(f,,z2);
while(y2<=y0)
z1=z0;
y1=y0;
z0=z2;
y0=y2;
h=2*h;
z2=z0+h;
y2=subs(f,,z2);
end
z1=z0;
a=min(z1,z2);
b=max(z1,z2);
eps=0.05;
z1=a+0.382*(b-a);
y1=subs(f,,z1);
z2=a+0.618*(b-a);
y2=subs(f,,z2);
while (abs(b-a)>eps);
   if (y1>=y2)
      a=z1;
      b=b;
      z1=a+0.382*(b-a);
       y1=subs(f,,z1);
      z2=a+0.618*(b-a);
       y2=subs(f,,z2);
   elseif y2>y1
      a=a;
      b=z2;
      x1=a+0.382*(b-a);
       y1=subs(f,,z1);
       z2=a+0.618*(b-a);
       y2=subs(f,,z2);
   end
end
z=(z1+z2)/2;
??? Function 'ge' is not defined for values of class 'sym'.

Error in ==> lsliu at 38
   if (y1>=y2)
页: [1]
查看完整版本: 求助高手