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

Magnitude and Phase of Fir Filters

This document discusses designing and analyzing different types of FIR filters. It uses MATLAB code to design bandpass, bandstop, highpass, and lowpass filters based on user-defined order, sampling frequency, and cutoff frequencies. The freqz function is then used to plot the amplitude and phase spectrum of each filter over different frequencies to analyze their characteristics.

Uploaded by

vasu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Magnitude and Phase of Fir Filters

This document discusses designing and analyzing different types of FIR filters. It uses MATLAB code to design bandpass, bandstop, highpass, and lowpass filters based on user-defined order, sampling frequency, and cutoff frequencies. The freqz function is then used to plot the amplitude and phase spectrum of each filter over different frequencies to analyze their characteristics.

Uploaded by

vasu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Magnitude and phase of fir filters:

clc
clear all
close all
n=input('Enter the order of the filter') ; % order of the FIR bandpass filter
fs=input('Enter the sampling frequency in Hz') ; % say sampling frequency of
the filter is 8Khz
fc1=input('Enter the value of low cutoff frequency in Hz'); % low cutoff
frequency
fc2=input('Enter the value of high cutoff frequency in Hz'); % high cutoff
frequency
wc1=2*(fc1/fs); % because FIR alaways take normalized frequency
wc2=2*(fc2/fs); % because FIR alaways take normalized frequency
x=fir1(n,[wc1 wc2],'bandpass',hamming(n+1))% for bandpass filter
y=fir1(n,[wc1 wc2],'stop',hamming(n+1))% for bandstp filter
z=fir1(n,wc2,'high',hamming(n+1))%for highpass filter
a=fir1(n,wc1,'low',hamming(n+1))%for low pass filter
%freqz is used to get the phase and amplitude spectrum for respective

%filters

figure,freqz(x,1,5000,fs),title('Amplitute and phase spectrum for Bandpass


filter')
figure,freqz(y,1,5000,fs),title('Amplitute and phase spectrum for Bandstop
filter')
figure,freqz(z,1,5000,fs),title('Amplitute and phase spectrum for High Pass
filter')
figure,freqz(a,1,5000,fs),title('Amplitute and phase spectrum for Low Pass
filter')

You might also like