I am multiplying two sine waves with the same frequency (f), but might have a phase difference 0 <-> 90 degrees. The product is a two frequency sinusoidal wave with f1 = f-f = DC and f2 = f+f = 2f. I now want to filter out the 2f component. I am currently sampling at Fs = 32 x f. I get a 40th order equiripple FIR filter in Matlab which is ok, but if I later am to increase the sampling rate to 64xf, 128xf etc the filter order gets very high.

I assume however that f1 will not be 0 Hz exactly but somewhere close to 0 Hz. Over this region the ripple in the passband might be unwanted. Can the ripple change that much over such a narrow range? (within whatever limit one has set as the maximum ripple in the passband).

I am using the Filter Design & Analysis tool in Matlab and saw that it does not seem like an equiripple filter has any ripple close to DC (0<->1Hz)? Is this correct?

I need a filter that can attenuate the 2f component with 60dB and need as little computing power as possible. (working on a MCU without FPU using fixed-point).

Is there any other filter that can do a better job than equiripple for what I described? I am open for other types of filters as IIR if someone can convince me of their advantages.

  • 3
    $\begingroup$ It's hard to understand what you mean... no filter has any ripple at DC --- because DC is just one frequency. Ripple occurs over a range of frequencies. Can you reformulate the question? What are you trying to achieve with very sharp roll-off rate and the DC gain should be very consistent ? $\endgroup$
    – Peter K.
    Aug 23, 2013 at 20:48
  • 1
    $\begingroup$ @PeterK.: I am sorry for the poor formulation of my question. I hope this edit will better it. $\endgroup$ Aug 24, 2013 at 10:53

2 Answers 2


You're correct; if the signal that you're applying to the input of the filter isn't exactly at DC (0 Hz), then you might see a slight difference in the amplitude of the output due to the filter's passband ripple. I would assert that for most applications, this is either imperceptible or negligible for typical values of passband ripple (1 dB or less). Are you sure that your application requires such insertion loss consistency?

If you are sure, then there are some things you can do to mitigate the problem:

  • Design a better equiripple filter. If 1 dB of passband ripple is too much, try designing one that has 0.5 dB. If that's too much, think about 0.1 dB. You see where I'm going here. True, there will be some limit beyond which it will be difficult to generate a numerically-realizable filter that has little enough ripple, but again, I would expect that it's quite unlikely that your application is intolerant of 0.1 dB of passband ripple. Also, ratcheting down the allowed ripple is going to have a direct impact on the required filter order, possibly to the point where it's no longer feasible to implement given your system's constraints.

  • Don't use an equiripple filter. With your latest edit to the question, you state that your goal is to attenuate your $2f$ frequency component by a minimum of 60 dB with as little processing power as possible. In that case, this might be a good application for an IIR filter. Digital IIR filters are usually realized as approximations to one of a few standard classes of analog prototype filters. Specifically, for your application, you might look at a Butterworth or Chebyshev type II structure.

    Both of these classes of filters offer no ripple across their passband, so they may be more amenable to your appilcation if you're picky about how much attenuation you see near DC. Plus, you can meet the same filter performance specifications (i.e. attenuate the unwanted component by at least 60 dB) with a much lower-order filter when compared to the equiripple FIR approach. If computational speed is a limiting factor in your system, this could be attractive.

    What do you give up with an IIR structure? FIR filters are nice because they are always BIBO stable. Plus, they are easier to implement robustly in finite-precision arithmetic (IIR implementations might need to use noise-shaping techniques to mitigate the effects of quantization error that is fed back into the filter). Lastly, symmetric FIR filters offer linear phase response, which can be nice for some applications.

    Linear phase response means that for a sinusoidal input, the phase lag induced by the filter is equal to a constant time delay, no matter what the sinusoid frequency is. This can be useful if you care about the phase of the filter output with respect to some other unfiltered signal. While it is possible to design linear-phase IIR filters, in general they do not have this property.

  • $\begingroup$ I was not aware of the major difference in filter order between FIR and IIR. If Matlab says that a IIR filter is stable is it then BIBO stable? I do not think the lack of linear phase response would mean anything as I am only interested in such a narrow range? $\endgroup$ Aug 24, 2013 at 23:16
  • $\begingroup$ If all of a discrete-time filter's poles are inside the unit circle, then it is, strictly speaking, BIBO stable. You can get MATLAB to tell you where the poles are using fdatool or fvtool. However, it is possible, due to the effects of finite precision arithmetic, for you to observe instability if you try to implement a filter whose poles are really close to the unit circle (the effects of quantization in the filter implementation effectively move the poles slightly). This would typically happen if you're trying to get a really sharp transition band. $\endgroup$
    – Jason R
    Aug 25, 2013 at 14:27

If you want to know the exact DC gain of your filter take the sum of the coefficients. This is true for an equiripple filter as well as any other FIR filter. There is no such thing as ripple at DC, because "ripple" is a term used to describe a magnitude variation over some range of frequencies.

If what you are looking for is a flat passband then equiripple can fit the bill. When using the fdatool in Matlab, notice that the equiripple FIR filter allows you to specify a parameter Apass. This paramter lets you adjust the maximum allowable amplitude of the ripples in the passband as shown below. By default it is set to 1, which means that you will have a maximum ripple of 1 dB in the passband.

MATLAB Filter Specification Diagram

If you are not constrained to FIR filters, then you might want to consider an IIR filter, depending on your needs. You can usually achieve the desired result with a lower filter order when using IIR. This means less computation and less delay.


Your Answer

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

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