Digital Signal Processing Reference
In-Depth Information
function [yout] = RealTimeFilter(h);
L = length(h); data(1:L) = 0;
K = 512; % K = 1 if h is already normalized
[r,c] = size(h); if (r > 1)&(c == 1) h = h'; end
[r,c] = size(h);
if (r == 1)&(c > 1)
while
cond
read x
% this is a user defined function
[data] = shift(data,-1);
data(L+1) = x;
yout = h*data'/K; % equation (2.10)
update cond
% this is a user defined operation
end
end
Figure 2.11
A Matlab
script to carry out concurrent (real-time) processing.
2.5.3 Frequency Domain Method
This technique utilizes the FFT to achieve filtering in the frequency domain. To
understand how this procedure is carried out, let
x
represent the data set of length
M
, and
h
, the filter coefficients of length
L+
1 as before. Furthermore, let the filter
length be less than the data length. If
y
is the output array and its length is chosen
to be
N
so that , then successful filtering can be carried out in the
frequency domain [2,5,6]. The condition above is derived from an application of
the convolution theorem and is required to avoid signal aliasing on the filter
output. Generally, if a radix 2 FFT is used,
N
is chosen to be a minimum power of
2, which is greater than or equal to
M+L
+1.
N
M
+
L
+
1
For the filtering procedure itself,
x
is chosen to be of length
N
and an
N
-point
FFT is used to give the discretized output
X
F
,
j
(
j
= 1,2,…,
N
). Likewise, the filter
h
is also zero-padded out to length
N
(i.e.,
for
j
>
L+
1) and Fourier
=
F
,
j
(
j
= 1,2,…,
N
). An inverse Fourier transform is
performed on the complex scalar product of
X
and
H
to yield the filtered output
y
,
h
0
j
transformed to form the output
H
used, although we can use the complex FFT to improve efficiency by a factor of 2
If
x
itself streams continuously from, say, an ADC interface, then it is useful
to take
N
samples to perform the convolution in the frequency domain with an
overlap of length
L
with the next set of samples. This is often referred to as the
overlap-save
method. The procedure is as follows:
1. Perform an
N
-point FFT on the filter coefficients,
h
j
after zero-
padding to length
N
(i.e.,
for
j
>
L+
1), to create
H
. Save
h
=
0
j
result for subsequent use.
1
The scalar product is defined for vectors
A
and
B
with elements
a
i
and
b
i
, as
g
i
=
a
i
b
i
(
i
= 1,2,…,
N
).