1
$\begingroup$

enter image description here

I apply an FIR filter passing the band around 50/1000 and attenuating the other three frequency components 30/1000, 70/1000 and 110/1000.

Both filters are generated using the Remez algorithm. The first filter is of length 300 and the second is of length 100.

Why is the beginning of the filtered signal attenuated and why is this attenuation effect stronger for a longer filter?

library(signal)
par(mfrow=c(3,2))

ch <- 
  sin(2*pi*1:1000/floor(1000/30)) +
  sin(2*pi*1:1000/floor(1000/50)) +
  sin(2*pi*1:1000/floor(1000/70)) +
  sin(2*pi*1:1000/floor(1000/110))

# FFT of signal
barplot(abs(fft(ch)[1:120]))

# unfiltered signal
plot(ch,type="l")

filter <- function(c0,d1,d2,n) {
  fir <- remez(n=n,f=c(0,c0-d2,c0-d1,c0+d1,c0+d2,1),a=c(0,0,1,1,0,0))

  freq <- freqz(fir,n=n)
  y <- signal::filter(as.vector(fir), 1, x=ch)

  # frequency response of filter
  barplot(abs(fft(y))[1:120])
  return(list(freq = freq, fir = fir, y = y))
}

f <- filter(2*50/1000,1/80,1/40,n=300)

# first filtered signal
plot(f$y, type="l")


f <- filter(2*50/1000,1/80,1/40,n=100)

# second filtered signal
plot(f$y, type="l")
$\endgroup$

3 Answers 3

4
$\begingroup$

The filter you designed is a linear phase filter, therefore, response of the filter will start at $N/2$th sample, where $N $ is the filter order. As $N$ increases so does the delay of the response. You can find this delay value by computing group delay of the filter.

In case you want to reduce the delay, you can design a minimum phase filter.

$\endgroup$
2
  • $\begingroup$ Nitpick: the delay of an $N$-tap linear-phase FIR filter is $\frac{N-1}{2}$ samples. An $N$-tap filter is of order $M$, and the delay is $\frac{M}{2}$. $\endgroup$
    – Jason R
    May 14, 2014 at 13:37
  • $\begingroup$ @Jason thankx for correction. Ill edit my answer to replace tap with order. $\endgroup$
    – learner
    May 14, 2014 at 16:51
2
$\begingroup$

For a $N$th order FIR filter, the first $N$ outputs are not valid, since they are the transient response of the filter. Check the "Steady State and Transient Response" section in this page: http://www.music.mcgill.ca/~gary/618/week1/signals.html

$\endgroup$
0
$\begingroup$

I think, if you have a

Xn[n] = {X0.x0, X1.x1,..,Xn.xn} //X0 Integer part, x0 fractional

and you have a

Hn[m] = {H0.h0, H1.h1,..,Hm.hm}

Then

Yn[i] = Hi.hi*Xi.xi + Hi+1.hi+1*Xi-1.xi-1 + .. +Hi+m.hi+m*Xi-m.xi-m

But when you begins multiplyng you don't have before to X0.x0,

Yn[0] = H0.h0*X0.x0 + H1.h1*X-1.x-1

X-1.x-1 = 0.0;

Then

Yn[0] = H0.h0*X0.x0

If m is very long the first m's values of Yn[i] will be lower too...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.