0% found this document useful (0 votes)
35 views

WN Input N Input B Fir1 (N, WN) Freqz (B)

The document discusses the design of various types of FIR filters including low pass, high pass, bandpass, and bandstop filters using both window-based and frequency sampling techniques. It includes code to design the filters, obtain their frequency responses using freqz, and plot the ideal and designed frequency response magnitudes for comparison. Filters of various orders are designed with different normalized cutoff frequencies or pass/stop bands.

Uploaded by

abhishek
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

WN Input N Input B Fir1 (N, WN) Freqz (B)

The document discusses the design of various types of FIR filters including low pass, high pass, bandpass, and bandstop filters using both window-based and frequency sampling techniques. It includes code to design the filters, obtain their frequency responses using freqz, and plot the ideal and designed frequency response magnitudes for comparison. Filters of various orders are designed with different normalized cutoff frequencies or pass/stop bands.

Uploaded by

abhishek
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

% low pass fir filter using window based technique

wn= input ('enter the normalised cut off frequency ');


n= input('enter the order of filter ');
b= fir1 (n, wn);
freqz(b)%instantaneous frequency response
output :
'enter the normalised cut off frequency = .45
'enter the order of filter= 2

% high pass fir filter using window based technique


n= input('enter the normalised cut off frequency ');
n= input('enter the order of filter ');
b = fir1(n,wn, 'high');
freqz(b)

output:
'enter the normalised cut off frequency = 0.55
'enter the order of filter = 48

%bandpass fir filter


n= input('enter the order of filter ');
wn1= input('lower cut off frequency ');
wn2 = input(' upper cut off frequency ');
wn= [wn1 , wn2 ];
b= fir1 (n, wn);
freqz(b)

output:
'enter the order of filter = 48
'lower cut off frequency = .35
upper cut off frequency = .65

%bandstop fir filter


n= input('enter the order of filter ');
wn1= input('lower cut off frequency ');
wn2 = input(' upper cut off frequency ');
wn= [wn1 , wn2 ];
b= fir1 (n, wn, 'stop');
freqz(b)

output:
'enter the order of filter = 48
'lower cut off frequency = .35
upper cut off frequency = .65

% low pass fir filter using frequency sampling technique


f = [0 0.6 0.6 1]; m = [1 1 0 0];
b = fir2(30,f,m);
[h,w] = freqz(b,1,128);
plot(f,m,w/pi,abs(h))
legend('Ideal','fir2 Designed')
title('Comparison of Frequency Response Magnitudes')

% high pass fir filter using frequency sampling technique


f = [0 0.6 0.6 1]; m = [0 0 1 1];
b = fir2(30,f,m);
[h,w] = freqz(b,1,128);
plot(f,m,w/pi,abs(h))
legend('Ideal','fir2 Designed')
title('Comparison of Frequency Response Magnitudes')

% bandpass fir filter using frequency sampling technique


f = [0 0.2 0.2 0.8 0.8 1 ]; m = [0 0 1 1 0 0 ];
b = fir2(30,f,m);
[h,w] = freqz(b,1,128);
plot(f,m,w/pi,abs(h))
legend('Ideal','fir2 Designed')
title('Comparison of Frequency Response Magnitudes')

% bandstop fir filter using frequency sampling technique


f = [0 0.2 0.2 0.8 0.8 1 ]; m = [1 1 0 0 1 1 ];
b = fir2(30,f,m);

[h,w] = freqz(b,1,128);
plot(f,m,w/pi,abs(h))
legend('Ideal','fir2 Designed')
title('Comparison of Frequency Response Magnitudes')

You might also like