Geoscience Reference
In-Depth Information
A running mean over eleven elements is designed and this i lter applied to
the input signal
x8
.
b8 = ones(1,11)/11;
m8 = length(b8);
y8 = filter(b8,1,x8);
h e phase of the output
y8
is corrected for causal indexing.
y8 = y8(1+(m8-1)/2:end-(m8-1)/2,1);
y8(end+1:end+m8-1,1) = zeros(m8-1,1);
Both input and output of the i lter are plotted.
plot(t,x8,t,y8)
h e i lter clearly reduces the amplitude of the sine wave. Whereas the input
signal
x8
has an amplitude of 2, the output
y8
has an amplitude of
max(y8)
ans =
1.1480
h e i lter reduces the amplitude of a sine with a period of 20 by
1-max(y8(40:60))/2
ans =
0.4260
i.e., by approximately 43%. h e elements 40 to 60 are used for computing the
maximum value of
y8
, in order to avoid edge ef ects. Nevertheless, the i lter
does not af ect the phase of the sine wave, i.e., both input and output are in
phase.
h e same i lter, however, has a dif erent impact on a dif erent input signal.
Let us design another sine wave
x9
, with a similar amplitude but with a
dif erent period of 15.
clear
t = (1:100)';
x9 = 2*sin(2*pi*t/15);
Applying a similar i lter and correcting the output
y9
for the phase shit of the
function
filter
yields
b9 = ones(1,11)/11;
m9 = length(b9);