fitting.m
来自「数值分析中的数值逼近方法以及曲线拟合算法」· M 代码 · 共 31 行
M
31 行
function [Fy a]=Fitting(x,y,n)
%curve fitting, y=f(x)
%Fy is the estimation of y at x
%a is the coefficients of poly
%n is the order
%Weight w==1;
n1=n+1;
Fy=zeros(n1,1);
Lox=length(x);
%Aa=d
A=zeros(n1,n1);
d=zeros(n1,1);
a=zeros(n1,1);
%compute the parameter
for i=1:n1
d(i)=sum(y.*(x.^(i-1)));
for j=1:n1
A(i,j)=sum(x.^(i+j-2));
end
end
%if(abs(det(A))<=10^(-3)) diap("check matrix");
%else
a=inv(A)*d
tp=fliplr(a');
Fy=polyval(tp,x);
%end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?