function [XI,YI]=interpL2(X,Y,n)
N1=length(X);
if (mod(N1,n)~=1) & (n~=1)
    disp('There are not enough points to do this.')
elseif n==N1-1
    XI=linspace(X(1),X(N1),N1*10);
    YI=interpL(X,Y,XI);
else
    if n==1
        Nint=N1-1;
    else
        Nint=floor(N1/n);
    end
    for k=1:Nint
        k0=1+(k-1)*10*Nint;
        k1=10*k*Nint;
        x=X(1+(k-1)*n:k*n+1);
        y=Y(1+(k-1)*n:k*n+1);
        xi=linspace(x(1),x(n+1),10*Nint);
        yi=interpL(x,y,xi);
        XI(k0:k1)=xi;
        YI(k0:k1)=yi;
    end
end