matlab指数拟合x=1993:1:2003y=[0.818691554 0.789061222 0.7516298340.738927407 0.7356786620.689186775 0.682934360.665770829 0.659170406 0.637114428 0.62024148 ];如何进行曲线拟合 得到拟合公式 y = a1 + exp(a2*x) 并得出R^2
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 23:34:54
matlab指数拟合x=1993:1:2003y=[0.818691554 0.789061222 0.7516298340.738927407 0.7356786620.689186775 0.682934360.665770829 0.659170406 0.637114428 0.62024148 ];如何进行曲线拟合 得到拟合公式 y = a1 + exp(a2*x) 并得出R^2
matlab指数拟合
x=1993:1:2003
y=[0.818691554 0.789061222 0.751629834
0.738927407 0.735678662
0.689186775 0.68293436
0.665770829 0.659170406 0.637114428 0.62024148 ];
如何进行曲线拟合 得到拟合公式 y = a1 + exp(a2*x)
并得出R^2
matlab指数拟合x=1993:1:2003y=[0.818691554 0.789061222 0.7516298340.738927407 0.7356786620.689186775 0.682934360.665770829 0.659170406 0.637114428 0.62024148 ];如何进行曲线拟合 得到拟合公式 y = a1 + exp(a2*x) 并得出R^2
按常理:按下面操作即可
在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function F=zhidao_fit_4(a,x)
F=a(1)+exp(a(2)*x);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下面输入:
x=1993:1:2003;
y=[0.818691554 0.789061222 0.751629834 0.738927407 0.735678662 0.689186775 0.68293436 0.665770829 0.659170406 0.637114428 0.62024148];
[A,res]=lsqcurvefit('zhidao_fit_4',0.001*ones(1,2),x,y);
A
结果:
A =
0.7080 -0.0953
但是作图的话,就不好了.
>> yy=zhidao_fit_4(A,x);
>> plot(x,y,'*',x,yy,'r')
差距比较大.
你看一下,你的x是在指数上面的,你的x那么大
建议你:
x=1:11;
y=[0.818691554 0.789061222 0.751629834 0.738927407 0.735678662 0.689186775 0.68293436 0.665770829 0.659170406 0.637114428 0.62024148];
[A,res]=lsqcurvefit('zhidao_fit_4',0.001*ones(1,2),x,y);
A
>> yy=zhidao_fit_4(A,x);
>> plot(x,y,'*',x,yy,'r')
这样做出来的图就好多了.
至于R^2
你最好给个表达式.