1.最小二乘原理 Matlab直接实现最小二乘法的示例: close x = 1:1:100; a = -1.5; b = -10; y = a*log(x)+b; yrand = y + 0.5*rand(1,size(y,2)); %%最小二乘拟合 xf=log(x); yf=yrand; xfa = [ones(1,size(xf,2));xf] w = inv(xfa*xfa')*xfa*yf';%直接拟合得到的结果 参考资料: 1.http://blog.csdn.net/lotus_
1.最小二乘原理 Matlab直接实现最小二乘法的示例: close x = 1:1:100; a = -1.5; b = -10; y = a*log(x)+b; yrand = y + 0.5*rand(1,size(y,2)); %%最小二乘拟合 xf=log(x); yf=yrand; xfa = [ones(1,size(xf,2));xf] w = inv(xfa*xfa')*xfa*yf';%直接拟合得到的结果 参考资料: 1.http://blog.csdn.net/lotus_