📄 fitting.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -