%
% 分段抛物线插值
%
clear all;
close all;

a = 0;
b = 1;
f = @(x) sqrt(x);
xi = a : 0.01 : b;   % 绘图点
nn = [5,10,20];
yi = zeros(length(xi),length(nn));

for kn = 1 : length(nn)
    n = nn(kn);
    X = linspace(a,b,n+1);
    Y = f(X);
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%  这里是你的代码  %%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
end

% 绘图
plot(xi,yi(:,1),'b+-', xi,yi(:,2),'r.-', xi,yi(:,3),'md-',xi,f(xi),'ks-');
legend('n=5','n=10','n=20','f(x)');
% hold on;
% plot(X,Y,'ok','markersize',10,'LineWidth',1.5); % 绘制插值节点
% hold off

