% Let f(t)=Sin(t). Plot sum_(k=-N)^(N) f(kh) Sinc[(t-kh)/h]
% for N=10 & 25, and h=pi & pi/4 respectively

clear
clf

h1=pi;
h2=pi/4;

N1=5;
N2=10;

s=2*pi/25;

for k=1:26
  t(k)=(k-1)*s;

  f11(k)=0;
  f12(k)=0;
 for i=-N1:N1
  f11(k)=f11(k)+sin(i*h1)*sinc((t(k)-i*h1)/h1);
  f12(k)=f12(k)+sin(i*h2)*sinc((t(k)-i*h2)/h2);
  ff1(k)=sin(t(k));
 end

  f21(k)=0;
  f22(k)=0;
 for i=-N2:N2
  f21(k)=f21(k)+sin(i*h1)*sinc((t(k)-i*h1)/h1);
  f22(k)=f22(k)+sin(i*h2)*sinc((t(k)-i*h2)/h2);
  ff2(k)=sin(t(k));
 end
end

subplot(211)
plot(t,f11,'g')
hold on
plot(t,ff1,'b')
plot(t,f12,'r')
axis([0 2*pi -2 2])
text(2,1.5,'f(t)=sin(t)(blue), N=5, h=pi(green), pi/4(red)')

subplot(212)
plot(t,f21,'g')
hold on
plot(t,ff2,'b')
plot(t,f22,'r')
axis([0 2*pi -2 2])
text(2,1.5,'f(t)=sin(t)(blue), N=10, h=pi(green), pi/4(red)')
