In: Electrical Engineering
Matlab
Design a FIR filter directly using fir1 function in matlab with parameter M = 50.
Design FIR filters with different M = 5, 10, 50, 100, 500 and plot their frequency responses H(e j?) on the same figure.
To design a filter using fir1, the order of the filter and cut-off frequency and type of the filter should be mentions. Since a parameter M is given without mentioning the details. Explicitly, M should be the order of filter. Let the filter be band pass filter with cut-off frequency between 0.35*pi and 0.65* pi. The command to design FIR filter is b = fir1(n,Wn,ftype), Where n is the order of filter , Wn is the cutoff frequency and ftype is the type of filter.
Matlab code:
clear all;
clc;
close all;
%%
M=input('Enter the order of the filter : '); % enter the value of
M
Wn=[0.35
0.65];
% give the lower and upper cut off frequency of band pass
filter
b = fir1(M,Wn);
% fir band pass filter with order M and cut off frequency Wn
freqz(b,1,512) % magnitude and pahse
response
Ouput: