lsqcurvefit拟合出现函数未定义是怎么回事!!!! 5
程序:functionf=curvefit_fun2(a,t)f=(a(1)/((1+(a(1)/60.2-1)*exp(-a(2)*(t-1954)))));%定义向量...
程序:function f=curvefit_fun2(a,t)
f=(a(1)/((1+(a(1)/60.2-1)*exp(-a(2)*(t-1954)))));
% 定义向量(数组)
x=1954:2016;
y=[60.2,61.5,62.8,64.6,66.0,67.2,66.2,65.9,67.3,69.1,70.4,72.5,74.5,76.3,78.5,80.7,83.0,85.2,87.1,89.2,90.9,92.4,93.7,95.0,96.259,97.5,98.705,100.1,101.654,103.008,104.357,105.851,107.5,109.3,111.026,112.704,114.333,115.823,117.171,118.517,119.85,121.121,122.389,123.626,124.761,125.786,126.743,127.627,128.453,129.227,129.988,130.756,131.448,132.129,132.802,133.450,134.091,134.735,135.404,136.072,136.782,137.462,138.271];
plot(x,y,'*',x,y); % 画点,并且画一直线把各点连起来
a0=[0.001,1]; % 初值
a=lsqcurvefit('f',a0,x,y);
disp(['a=' num2str(a)]); % 显示结果
拟合不出结果,
未定义函数或变量 'f'。
出错 lsqcurvefit (line 202)
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); 展开
f=(a(1)/((1+(a(1)/60.2-1)*exp(-a(2)*(t-1954)))));
% 定义向量(数组)
x=1954:2016;
y=[60.2,61.5,62.8,64.6,66.0,67.2,66.2,65.9,67.3,69.1,70.4,72.5,74.5,76.3,78.5,80.7,83.0,85.2,87.1,89.2,90.9,92.4,93.7,95.0,96.259,97.5,98.705,100.1,101.654,103.008,104.357,105.851,107.5,109.3,111.026,112.704,114.333,115.823,117.171,118.517,119.85,121.121,122.389,123.626,124.761,125.786,126.743,127.627,128.453,129.227,129.988,130.756,131.448,132.129,132.802,133.450,134.091,134.735,135.404,136.072,136.782,137.462,138.271];
plot(x,y,'*',x,y); % 画点,并且画一直线把各点连起来
a0=[0.001,1]; % 初值
a=lsqcurvefit('f',a0,x,y);
disp(['a=' num2str(a)]); % 显示结果
拟合不出结果,
未定义函数或变量 'f'。
出错 lsqcurvefit (line 202)
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询