⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polyfit.m

📁 利用最小二乘解法进行离散数值拟合
💻 M
字号:
function [a,A,g]=polyfit(x,y,n)
%x,y is measurement data,n is the degree of polyfitting polynomial,r is
%weight function,the r defauts is set to 1
%x=[0.0 0.1 0.2 0.3 0.5 0.8 10];y=[1.0 0.41 0.50 0.61 0.91 2.02 2.46]
[r,c]=size(x);
a=zeros(1,n+1);
g=zeros(1,n+1);
A=zeros(n+1);
%p=cell(1,1);
%p=0;
%phi=cell(1,n+1);
%syms k;
%for i=1:n+1
   %phi(1,i)=x(1,k).^(i-1);    
   %p=p+a(1,i).*phi(1,i);
%end%比较注释部分与程序的区别,两种不同的思路
for i=1:n+1
    for j=1:n+1
        A(i,j)=splus(x,x,i,j,c);
    end
    g(1,i)=splus(y,x,2,i,c);
end
a=dirtri(A,g');%By comparison, the accuracy of the best wants check

function anwser=splus(e1,e2,e3,e4,e5)
anwser=0;
for i=1:e5
    anwser=anwser+((e1(1,i)).^(e3-1)).*((e2(1,i)).^(e4-1));
end
    


    
   


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -