MATLAB实现拟合算法
作者:互联网
线性最小二乘法
解方程组方法
x = [19 25 31 38 44]';
y = [19.0 32.3 49.0 73.3 97.8]';
r = [ones(5,1),x.^2];
ab = r\y;
x0 = 19:0.1:44;
y0 = ab(1)+ab(2)*x0.^2;
plot(x,y,'o',x0,y0,'r');
多项式拟合
x0 = [1990 1991 1992 1993 1994 1995 1996];
y0 = [70 122 144 152 174 196 202];
a = polyfit(x0,y0,1);
y97 = polyval(a,1997)
y98 = polyval(a,1998)
标签:polyval,ab,19,44,算法,MATLAB,拟合,y0,x0 来源: https://www.cnblogs.com/java-six/p/16207074.html