%% Example 4.11 Lowpass/highpass filtered signals
% I filter f\left(t\right)=sin\left(8\pi t\right)+0\ldotp 25\text{ }sin\left(64\pi t\right),\text{ }t\text{ }in\text{ }\left\lbrack 0,1\right\rbrack , using the filters T_0 =\frac{1}{4}\left(\delta_{-1} +2\delta_0 +\delta_1 \right) and T_1 =\frac{1}{4}\left(-\delta_{-1} +2\delta_0 -\delta_1 \right)\ldotp \text{ }I'll use a window to do it. The window will cut the function off outside [0.1,0.9].

syms t
f = @(t) sin(8*pi*t) + 0.25*sin(64*pi*t);
fplot(f,[0,1])

%
% For the digital version, I'll sample at 100 points.

F = eval(vectorize(f));
T = 1:100;
X = F(T/100);
plot(X)

% This is a little more jagged than the original function, but not much.
%
% I multiply this by the Bartlett-Hann window function to obtain a cutoff and somewhat modified X.

w = barthannwin(100);
Xcut = w'.*X;
plot(Xcut)

%
% Now I apply the filters.

T = 2:99;
y0 = 1/4*(Xcut(T-1)+2*Xcut(T)+Xcut(T+1));
plot(y0,'r--'), hold on
xticklabels({'0','0.1','0.2','0.3','0.4','0.5','0.6','0.7','0.8','0.9','1'}), hold on
y1 = 1/4*(-Xcut(T-1)+2*Xcut(T)-Xcut(T+1));
plot(y1,'b:','LineWidth',1)
title('Filters in Example 4.11')