%% Example 2.9 Effect of filter
% I graph the analog signal f(x) = 2 \sin(12\pi x) + 0.25 \sin(36\pi x).

X = [0:0.001:1]; plot(X,2*sin(12*pi*X)+0.5*sin(36*pi*X))

%
% Next I sample at rate N=48 and plot.

f = 2*sin(12*pi*1/48*(0:47))+0.5*sin(36*pi*1/48*(0:47));
plot(1/48*(0:47),f,'o')
hold on
for j = 1:48
    plot([1/48*(j-1),1/48*(j-1)],[0,2*sin(12*pi*1/48*(j-1))+0.5*sin(36*pi*1/48*(j-1))],'g')
end
hold off

%
% Next I apply the filter corresponding to the shift invariant operator T=\text{ }\frac{1}{4}\left(S+2I+S^{-1} \right). I get the signal. I plot the result.

c = cos(pi/8); 
z = 2*c^2*sin(pi/4*(0:47))+ (1-c^2)*sin(3*pi/4*(0:47))/2;
plot(1/48*(0:47),z,'o')
hold on
for j = 1:48
    plot([1/48*(j-1),1/48*(j-1)],[0,2*c^2*sin(pi*1/4*(j-1))+(1-c^2)*sin(3*pi/8*(j-1))/2],'g')
end
hold off