%M-Code that passes a composite waveform through a bandpass
%filter. The filter 'h1' must be present in the Matlab workspace
% I Wells March 2012
fs=8000;
t=0:1/fs:10; %samples of the sine waves
test1=sin(2*pi*1100*t); %a sine wave of 1100 Hz 
test2=sin(2*pi*2000*t)/50; %a sine wave of 2000 Hz 
test3=sin(2*pi*4100*t); %a sine wave of 4100 Hz 
x=test1+test2+test3; % add the sine waves together
%pass the composite wave 'x' through the filter 'h1'
% giving the result 'res'
res=filter(h1,1,x); 
%find spectrum of the composite 'x'
[Hx,fx]=freqz(x,1,512,fs);
%find spectrum of the result 'res'
[Hres,fres]=freqz(res,1,512,fs);
subplot(2,1,1), plot(fx,abs(Hx))
subplot(2,1,2), plot(fres,abs(Hres))
