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

📄 l2.m

📁 fit programme for a serials of data
💻 M
字号:
function X=L2(x,y,x1)
% input x is a vector that contains a list of abscissas
%       y is a vector that cntains a list of ordinates
%       x1 is the number at where the interpolation is to be obained
% output X is the parabola interpolation at x1
n=length(x);
j=-1;
for i=1:n-1
    if x1<x(i+1)&&x1>x(i)
       j=i;
       break;
    end
end
if j==-1
   'false';
   return;
end
if j==n-1
   i=j;
else 
    if j==1
       i=j+1;
    else
        e1=abs(x1-x(j-1));
        e2=abs(x1-x(j+2));
        if e1>e2
           i=j;
        else
          i=j+1;
        end
    end
end
X=0;
for j=i-1:i+1
    c=1;
    for k=i-1:i+1
        if k~=j
           c=c*(x1-x(k))/(x(j)-x(k));
        end
    end
    X=X+y(j)*c;    
end

⌨️ 快捷键说明

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