Reply by AJ "no z" Johnson November 17, 20042004-11-17
"Crimson_M" <crimson_m@hotmail.com> wrote in message
news:9ba2ff64.0411151405.75091349@posting.google.com...
> How can I go about compensating for FIR filter integer delay, for the > case of M even (odd length filter)? How about for M odd? I'm trying to > implement a FIR differentiator in Matlab, first using a Kaiser window, > and then other windows with varying lengths for comparison. > > Thanks, > Brandon
As Rune pointed out, you need to delay the unfiltered paths commensurate with the filtered path. If your FIR filter is linear-phase, then the imparted delay is indeed (N-1)/2. This is nice for odd N, but, as you noticed, not so nice for even N. Try filtering the un-filtered path with what's called a "fractional delay filter" that has the same group delay as your FIR filter. A fair approximation of a fractional delay filter is a sampled SINC function: D=(N-1)/2; h=sinc((0:N-1)-D); Where h is the FIR coefficients of the fractional delay filter. I'm sure there are better ways to compute the coefficients that have better edge effects (better over-all flat frequency response). HTH, Aj
Reply by Rune Allnor November 17, 20042004-11-17
allnor@tele.ntnu.no (Rune Allnor) wrote in message news:<f56893ae.0411160009.26702ef0@posting.google.com>...
> crimson_m@hotmail.com (Crimson_M) wrote in message news:<9ba2ff64.0411151405.75091349@posting.google.com>... > > How can I go about compensating for FIR filter integer delay, for the > > case of M even (odd length filter)? How about for M odd? I'm trying to > > implement a FIR differentiator in Matlab, first using a Kaiser window, > > and then other windows with varying lengths for comparison. > > In general, you can't do much about the delay. In off-line applications, > you can avoid the delay by using zero phase filters. > > In on-line applications you just have to accept the delay. If you need > to syncronize two data streams, one filtered and one unfiltered, you will > have to delay the filtered stream to match up with the filtered stream.
Ouch, that didn't make much sense. Try "you will have to delay the UNfiltered stream to match up with the filtered stream" instead... Rune
Reply by Crimson_M November 16, 20042004-11-16
Dan Hensley <dan@somewhere.net> wrote in message news:<pan.2004.11.15.22.27.48.971492@somewhere.net>...
> On Mon, 15 Nov 2004 14:05:50 -0800, Crimson_M wrote: > > > How can I go about compensating for FIR filter integer delay, for the > > case of M even (odd length filter)? How about for M odd? I'm trying to > > implement a FIR differentiator in Matlab, first using a Kaiser window, > > and then other windows with varying lengths for comparison. > > > > Thanks, > > Brandon > > Are you using filtfilt to do the filtering? > > Dan
No. I was unaware of this function. However, on checking the help file for filtfilt() it says: Note that FILTFILT should not be used with differentiator and Hilbert FIR filters, since the operation of these filters depends heavily on their phase response.
Reply by Rune Allnor November 16, 20042004-11-16
crimson_m@hotmail.com (Crimson_M) wrote in message news:<9ba2ff64.0411151405.75091349@posting.google.com>...
> How can I go about compensating for FIR filter integer delay, for the > case of M even (odd length filter)? How about for M odd? I'm trying to > implement a FIR differentiator in Matlab, first using a Kaiser window, > and then other windows with varying lengths for comparison.
In general, you can't do much about the delay. In off-line applications, you can avoid the delay by using zero phase filters. In on-line applications you just have to accept the delay. If you need to syncronize two data streams, one filtered and one unfiltered, you will have to delay the filtered stream to match up with the filtered stream. Rune
Reply by Dan Hensley November 15, 20042004-11-15
On Mon, 15 Nov 2004 14:05:50 -0800, Crimson_M wrote:

> How can I go about compensating for FIR filter integer delay, for the > case of M even (odd length filter)? How about for M odd? I'm trying to > implement a FIR differentiator in Matlab, first using a Kaiser window, > and then other windows with varying lengths for comparison. > > Thanks, > Brandon
Are you using filtfilt to do the filtering? Dan
Reply by Crimson_M November 15, 20042004-11-15
How can I go about compensating for FIR filter integer delay, for the
case of M even (odd length filter)? How about for M odd? I'm trying to
implement a FIR differentiator in Matlab, first using a Kaiser window,
and then other windows with varying lengths for comparison.

Thanks,
Brandon