matlab中关于Lsqnonlin函数的问题,总是出现错误 20
Errorin==>cfit2at2[det,resnorm,residual]=lsqcurvefit(@(c,Data)cfiting(c,Data),c0,Data...
Error in ==> cfit2 at 2
[det,resnorm,residual]= lsqcurvefit ( @(c,Data)cfiting(c,Data), c0,Data, resident);
??? Error using ==> lsqcurvefit at 253
Function value and YDATA sizes are incommensurate.
代码如下
function f =cfiting( c,Data)
f = c(1)/(1+(c(1)/31.26-1)*exp(c(2)*(Data-1979)));
c0=[1800 0.2];
[det,resnorm,residual]= lsqcurvefit ( @(c,Data)cfiting(c,Data), c0,Data, resident);
Data resident 均为32维的列向量Data=(1979:2010)'
resident =
31.2600
32.0900
33.3900
35.4500
40.5200
43.5200
47.8600
51.4500
55.6000
60.1400
64.8200
68.6500
73.2200
80.2200
87.6900
93.9700
99.1600
103.3800
109.4600
114.6000
119.8500
124.9200
132.0400
139.4500
150.9300
165.1300
181.9300
196.8300
212.3800
228.0700
241.4500
251.0300 展开
[det,resnorm,residual]= lsqcurvefit ( @(c,Data)cfiting(c,Data), c0,Data, resident);
??? Error using ==> lsqcurvefit at 253
Function value and YDATA sizes are incommensurate.
代码如下
function f =cfiting( c,Data)
f = c(1)/(1+(c(1)/31.26-1)*exp(c(2)*(Data-1979)));
c0=[1800 0.2];
[det,resnorm,residual]= lsqcurvefit ( @(c,Data)cfiting(c,Data), c0,Data, resident);
Data resident 均为32维的列向量Data=(1979:2010)'
resident =
31.2600
32.0900
33.3900
35.4500
40.5200
43.5200
47.8600
51.4500
55.6000
60.1400
64.8200
68.6500
73.2200
80.2200
87.6900
93.9700
99.1600
103.3800
109.4600
114.6000
119.8500
124.9200
132.0400
139.4500
150.9300
165.1300
181.9300
196.8300
212.3800
228.0700
241.4500
251.0300 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询