function A16

% B-Splines Phi zeichnen

x  = linspace(-0.3,5.3,1000);
i0 = (x>=0) & (x<1);
i1 = (x>=1) & (x<2);
i2 = (x>=2) & (x<3);
i3 = (x>=3) & (x<4);
i4 = (x>=4) & (x<5);

Phi0 = i0;
Phi1 = x.*i0 + (2-x).*i1;
Phi2 = (x.^2.*i0 + (-2*x.^2+6*x-3).*i1 + (x-3).^2.*i2) / 2;
Phi3 = (x.^3.*i0 + (-3*x.^3+12*x.^2-12*x+4).*i1 + (3*x.^3-24*x.^2+60*x-44).*i2 - (x-4).^3.*i3) / 6;
Phi4 = (x.^4.*i0 + (-4*x.^4+20*x.^3-30*x.^2+20*x-5).*i1 + (6*x.^4-60*x.^3+210*x.^2-300*x+155).*i2 + (-4*x.^4+60*x.^3-330*x.^2+780*x-655).*i3 + (x-5).^4.*i4) / 24;

plot(x,Phi0,'k');
hold on;
plot(x,Phi1,'r');
plot(x,Phi2,'g');
plot(x,Phi3,'b');
plot(x,Phi4,'m');
axis([x(1) x(end) -0.1 1.1]);
xlabel x;
title('B-Splines');
legend('\Phi_0','\Phi_1','\Phi_2','\Phi_3','\Phi_4');


