clear;clc;close all format compact %% 正态分布的拟合 % 生成随机数 num = 50; y = randn(1000,1); x = 1:num; y = hist(y,num); xx = x(:); yy = y(:); % Set up fittype and options. ft = fittype('y0+(a/(w*sqrt(pi/2)))*exp(-2*((x-xc)/w).^2)', 'independent', 'x', 'depend
matlab中没有切比雪夫拟合的现成算法,这里把我程序中的这部分抽出来,说一下. 1.首先是切比雪夫计算式 function [ res ] = ChebyShev(num,i) res=; elseif i== res=num; else res=*num*ChebyShev(num,i-)-ChebyShev(num,i-); end end 2.计算拟合系数 function [ coeff ] = ChebyCoeff( xfile,timefile ) x=load(xfile); t
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_