

% This program introduces the concepts of low-, high-, and bandpass filters



% Load data
load sumatra_transverse
dt=1/20;  % seconds

subplot(4,1,1)
plot(Ttime,Tdata)
ylabel(' Amplitude (m/s) ')
title(' Original seismogram ')

% taper ends before filtering
Tdata=taper(Tdata,-1000);
Tdata=taper(Tdata,1000);

subplot(4,1,2)
n=2;
T0=30;
plot(Ttime,lowpass(Tdata,dt,1/T0,n))
ylabel(' Amplitude (m/s) ')
title(sprintf(' Lowpass T=%g s',T0))

subplot(4,1,3)
n=2;
T0=10;
plot(Ttime,highpass(Tdata,dt,1/T0,n))
ylabel(' Amplitude (m/s) ')
title(sprintf(' Highpass T=%g s',T0))


subplot(4,1,4)
n=2;
T1=60; T2=150;
plot(Ttime,bandpass(Tdata,dt,1/T2,1/T1,n))
xlabel(' Time (s) ')
ylabel(' Amplitude (m/s) ')
title(sprintf(' Bandpass T_1=%g s - T_2=%g s',T1,T2))
