Magnitude and Phase of Fir Filters
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