clf
clear all
set(0,'defaultaxesfontsize',22);
t=-1.5:.001:1.5;
t=t+0.0000001;
%
x=(pi/5)*(sin(5*t).*sin(15*t))./(pi*t).^2;
%
plot(t,x,'Linewidth',3)
Ts=2*pi/40;
ts=-1.5:Ts:1.5;
%ts=ts+0.0000001;
xs=(pi/5)*(sin(5*ts).*sin(15*ts))./(pi*ts).^2;
%
xr=zeros(size(t));
for k=1:length(ts),
xr=xr+Ts*xs(k)*(sin((pi/Ts)*(t-ts(k)))./(pi*(t-ts(k))));
end
plot(t,x,'Linewidth',3)
grid
axis([min(t) max(t) -1 5])
set(gca,'XTick',[min(t):0.5:max(t)],'YTick',[-1:5])
hold on
plot([0 0],[-1 5],'k','Linewidth',3)
plot([-1.5 1.5],[0 0],'k','Linewidth',2)
plot(ts,xs,'rx','MarkerSize',18,'Linewidth',4)
plot(t,xr,'r','Linewidth',3)
for kk=7:13,
Y(kk-6,:)=Ts*xs(kk)*(sin((pi/Ts)*(t-ts(kk)))./(pi*(t-ts(kk))));
end
plot(t,Y(1,:),'--',t,Y(2,:),'--',t,Y(3,:),'--',t,Y(4,:),'--', ...
    t,Y(5,:),'--',t,Y(6,:),'--',t,Y(7,:),'--','Linewidth',2)
title('Sampling Theory');
hold off

