On Fri, 13 Aug 2004 16:43:51 -0500, Richard Owlett
<rowlett@atlascomm.net> wrote:
(snipped)
>
>I think I was going in that direction.
>
>input(1)*h(1) + input(2)*h(2) + ... + input(n+0)*h(n) = OUTPUT(1)
>input(2)*h(1) + input(3)*h(2) + ... + input(n+1)*h(n) = OUTPUT(2)
>input(3)*h(1) + input(4)*h(2) + ... + input(n+2)*h(n) = OUTPUT(3)
>|
>repeat M-N times ( M=length input vector )
>
>That handles FIR case.
>What to do with IIR where h is N x2 ?
Hi Richard,
I'm not sure I can answer your question,
but I'll give it a try.
My Eq. (5-4), on page 158, gives the necessary computations
to implement a tapped-delay line FIR filter. That equation
is the infamous "convolution equation" as it pertains to
nonrecursive (tapped-delay line) FIR filters.
I tried to introduce that equation as slowly, and gently,
as I could.
For various values of time-index n, Eq. (5-4) for a
four-tap filter goes like this:
n=3: y(3) = h3*x(3) + h2*x(2) + h1*x(1) + h0*x(0)
n=4: y(4) = h3*x(4) + h2*x(3) + h1*x(2) + h0*x(1)
n=5: y(5) = h3*x(5) + h2*x(4) + h1*x(3) + h0*x(2)
n=6: y(6) = h3*x(6) + h2*x(5) + h1*x(4) + h0*x(3)
etc.
So, to implement nonrecursive (tapped-delay line) FIR filters,
your computations are
sum the products to compute an output sample
shift input sequence relative to filter coeffs
sum the products to compute an output sample
shift input sequence relative to filter coeffs
sum the products to compute an output sample
shift input sequence relative to filter coeffs
sum the products to compute an output sample
etc.
I don't know about Scilab, but MATLAB has a
"filter" command that's used to filter some
time-domain "x" variable (a list of input sample values)
using a filter that's defined by its feedforward and
feedback coefficients. For nonrecursive FIR filters,
the feedforward coefficients needed by MATLAB are the
FIR filter's coefficients (h), and the feedback
coefficients needed by MATLAB turn out to be a simple
single value of one. In MATLAB language, filtering
an input sequence, x, with an FIR filter looks like:
Output = filter([h0,h1,h2,h3],1,x);
Maybe Scilab is similar to the above, I don't know.
That above MATLAB command implements my Eq. (6-1) on
page 213. [Please note that there is a "typo" in Eq.
(6-1) that I'm desperately trying to get the
publisher to correct. In Eq. (6-1) the term
"h(4)x(n-4)" should NOT be there. Please cross out
that h(4)x(n-4) term.]
For an IIR filter, my Eq. (6-2), on page 214, gives the
necessary computations to implement the IIR filter in
Figure 6-3. In MATLAB language, filtering
an input sequence, x, with the Figure 6-3 IIR filter
looks like:
Output = filter([b(0),b(1),b(2),b(3)],[1,-a(1),-a(2),-a(3)],x);
No, the minus signs for the above a(k) feedback coefficients
are not a mistake. The minus signs are necessary because
of the way MATLAB expects the feedback coefficients to
be defined.
If you want to implement IIR filtering using some sort
of "for" loop, you need to define variables for the
instantaneous values at the output of each delay element
in Figure 6-3. Then those variables are updated in
preparation for computing a new filter output sample.
Here's an example referring to my Figure 6-3:
Let's call the x(n-1) value by the name "x1",
call the x(n-2) value by the name "x2",
call the x(n-3) value by the name "x3",
and
let's call the y(n-1) value by the name "y1",
call the y(n-2) value by the name "y2",
call the y(n-3) value by the name "y3".
OK, next we set those six variables all to zero.
That's our "initial condition" of the IIR filter.
Now we dive into a "computational loop", like this,
to compute our first IIR filter output using my
Eq. (6-2):
y(0) = b0*x(0) + b1*x1 + b2*x2 + b3*x3
+ a1*y1 + a2*y2 + a3*y3.
That y(0) is our 1st filter output value. Next we
prepare for a new computation by updating the variables
representing the outputs of the filter's delay
elements. That "updating" is:
x1 = x(0), x2 = x1, x3 = x2,
y1 = y(0), y2 = y1, y3 = y2.
Now we're ready to use the next input sample, x(1),
to compute the next output sample y(1). That computation
is a repeat (we're in a computational loop, right?)
of the above, which we write as:
y(1) = b0*x(1) + b1*x1 + b2*x2 + b3*x3
+ a1*y1 + a2*y2 + a3*y3.
Using the time-domain index n, we can say
our filter computation inside the "for" loop is:
y(n) = b0*x(n) + b1*x1 + b2*x2 + b3*x3
+ a1*y1 + a2*y2 + a3*y3.
Right after computing a y(n) output sample value,
we update the x1, x2, x3, y1, y2, & y3 values in
preparation for computing the next output y(n+1).
We stop looping when we run out of x(n) inputs samples
to filter.
Sheece! I've rambled on like crazy here.
Am hoping the above helps ya' a little Richard.
[-Rick-]
Where am I?
In the Village.
What do you want?
Information.
Whose side are you on?
That would be telling ... We want Information.
You won't get it.
By hook or by crook ... we will.
Who are you?
The new Number Two.
Who is Number One?
You are Number Six.
I am not a number ... I am a free man!
(Mocking laughter)