问题补充:
如何用matlab进行拟合,用最小二乘法?
答案:
xi=[0.019,0.023,0.027]; % x data
yi=[430,380,256]; % y data
abc0=[4,0.5,5]; % initial values%%初始值设定
abc = lsqcurvefit(@fun,abc0,xi,yi)%%xi和yi就是自变量和因变量的值,那么就相当于yi=(abc(1)*(1-xi/abc(2))+xi/abc(2)).^abc(3),开始拟合时abc去初始值abc0,然后进行迭代拟合,直到小于规定的误差.
% target function
function y = fun(abc,x)
y = (abc(1)*(1-x/abc(2))+x/abc(2)).^abc(3);%%要拟合的函数表达式
abc = 31.2588 -3.9585 1.7033