Geoscience Reference
In-Depth Information
where
N
is the order of the i lter. A number of the frequency-domain tools
provided by MATLAB cannot simply be applied to non-causal i lters that
have been designed for applications in earth sciences. Hence, it is common
to carry out phase corrections in order to simulate non-causality. For
example frequency-selective i lters, as will be introduced in Section 6.9, can
be applied using the function
filtfilt
, which provides zero-phase forward
and reverse i ltering.
h e functions
conv
and
filter
that provide digital i ltering in MATLAB
are best illustrated in terms of a simple running mean. h e
n
elements of
the vector
x
(
t
1
),
x
(
t
2
),
x
(
t
3
), …,
x
(
t
n
) are replaced by the arithmetic means of
subsets of the input vector. For instance, a running mean over three elements
computes the mean of inputs
x
(
t
n
-1
),
x
(
t
n
),
x
(
t
n
+1
) to obtain the output
y
(
t
n
).
We can illustrate this simply by generating a random signal
Movies
6.1-6.4
clear
t = (1:100)';
rng(0)
x1 = randn(100,1);
designing a i lter that averages three data points of the input signal
b1 = [1 1 1]/3;
and convolving the input vector with the i lter
y1 = conv(x1,b1);
h e elements of
b1
are the weights of the i lter. In our example all i lter weights
are the same and equal to 1/3. Note that the
conv
function yields a vector that
has a length of
n
+
m
-1, where
m
is the length of the i lter.
m1 = length(b1);
We can explore the contents of our workspace to check the length of the
input and output of
conv
. Typing
whos
yields
Name Size Bytes Class Attributes
b1 1x3 24 double
m1 1x1 8 double
t 100x1 800 double
x1 100x1 800 double
y1 102x1 816 double