matlab的拟合问题!!谢谢
各位大侠,我想预测人口,然后通过matlab进行人口拟合(通过lsqcurvefit拟合)建立,首先建立了.m文件,如下function f=cc2(x, tdata)
f=x(1)/(1+(x(1)/x(2)-1)*exp(-1*x(3)*tdata))
然后执行程序
tdata=1979:1:2010;
cdata=1e+02*[31.41
33.29
36.69
44.95
59.52
74.13
88.15
93.56
105.44
120.14
141.6
167.78
226.76
268.02
335.97
412.71
449.15
482.89
527.75
580.33
632.56
701.24
724.57
746.62
778.27
800.8
827.75
871.1
912.37
954.28
995.01
1037.2
]
x0=[10000000,314100,0.1];
x=lsqcurvefit('cc2',x0,tdata,cdata)
f=cc2(x,tdata)
结果出现以下错误
??? Error using ==> mldivide
Matrix dimensions must agree.
Error in ==> cc2 at 3
f=x(1)/(1+(x(1)/x(2)-1)*exp(-1*x(3)*tdata))
Error in ==> lsqcurvefit at 209
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue.
该怎么改进,求指教!!