% eda09_08
% amplitude spectrum of uniform smoothing filter

% standard set up of time and frequency
N=256;
Dt=0.01;
tmax=Dt*(N-1); 
t=Dt*[0:N-1]'; 
fmax=1/(2.0*Dt);
df=fmax/(N/2);
f=df*[0:N/2,-N/2+1:-1]'; 
Nf=N/2+1;
dw=2*pi*df;
w=dw*[0:N/2,-N/2+1:-1]';
Nw=Nf;

% evaluate fourier transform of filter of length L
T1=3*Dt;
s1 = sinc(w(1:Nf)*T1/(2*pi));
sa1 = abs(s1);

figure(1);
clf;
subplot(2,1,1);
set(gca,'LineWidth',2);
hold on;
axis( [0, fmax, 0, 1] );
plot( f(1:Nf), sa1, 'k-', 'LineWidth', 2);
xlabel('frequency, Hz');
ylabel('|s| for L=3');

% evaluate fourier transform of filter of length L
T2=21*Dt;
s2 = sinc(w(1:Nf)*T2/(2*pi));
sa2 = abs(s2);

subplot(2,1,2);
set(gca,'LineWidth',2);
hold on;
axis( [0, fmax, 0, 1] );
plot( f(1:Nf), sa2, 'k-', 'LineWidth', 2);
xlabel('frequency, Hz');
ylabel('|s| for L=21');