# Designing ideal lowpass filter in the form of FIR

How to design a ideal lowpass filter by cutoff frequency of π/4 in the form of FIR filter by 64 samples using matlab?

• Do you have any thoughts on it? – Rodrigo de Azevedo May 8 at 8:15

You don't.

An ideal low pass FIR filter has infinite length so the requirements of "ideal low pass" and "64 taps" are mutually exclusive.

You can approximate an ideal filter, but the best way to do this depends on the specific requirement and trade-offs of your application. This being said, Richard's answer is a really good starting point :-)

• I have a basic question...is 64 samples 64 taps? and if yes, what is the n in freqz(b,a,n) in matlab function? Will it be 64 here? – DSP Novice May 8 at 16:29
• 64 was my interpretation of the length of the FIR filter. The $n$ in freqz is different: it's the number of frequencies you want to display or calculate. – Hilmar May 9 at 11:53
• The main point is that you mentioned: Trade-off. Thanks. – Mohammadsadeq Borjiyan Jun 5 at 12:41
b = fir1(63, 0.25)

figure(1)

freqz(b,1,256)


We cannot design an ideal filter! So we should trade off our requirements and approximate the best filter. In this case:

b=firls(63,[0,0.25,0.28,1],[1,1,0,0]);

figure()

freqz(b)

may be an acceptable solution. Also we can use fir1 function instead.