回车后出现:
>> k=lsqcurvefit(@myfun,k,c,l)
??? Error using ==> optim\private\lsqncommon
User supplied function failed with the following error:
Input argument "l" is undefined.
Error in ==> lsqcurvefit at 149
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。作者: madio 时间: 2010-3-20 10:37
我给你改了一下,不知道是不是符合你的要求!
function w=myfun(k,c);
l=[36.8,31.8,43.8,36.8,32.1,45.1,35.9,32.1];
w=k*c.^2.*l
>>c=[24.8,21.3,27.9,24.8,21.6,31.8,22.9,21.6];
>> w=[765,482,1162,737,482,1389,652,454];
>> k=0;
>> k=lsqcurvefit(@myfun,k,c,w)
运行结果:
Optimization terminated: norm of the current step is less
than OPTIONS.TolX.