x1=[2007,2008,2009,2010,2011];
x2=[3.96,3.67,3.31,3.06,3.06];
x=[x1,x2];
y=[295.98,300.18,304.44,308.77,313.15];
fun=inline('1/(a(1)+(a(2)*exp(-x(:,2).*(x(:,1)-2006))))','a','x');
a=lsqcurvefit(fun,[3.5 3.5],x,y);
为什么老是
run('D:\MATLAB7\work\ymlogistic.m')
??? Error using ==> run
Error using ==> optim\private\lsqncommon
Function value and YDATA sizes are incommensurate.
??? Error using ==> optim\private\lsqncommon
Function value and YDATA sizes are incommensurate.
Error in ==> lsqcurvefit at 149
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in ==> ymlogistic at 6
a=lsqcurvefit(fun,[3.5 3.5],x,y);
>>
改成如下:
x1=[2007,2008,2009,2010,2011]';结果:
a =
0.0033 0.0064