There are several functions built-in to MATLAB which can be used to create various types of filters. These functions make it possible for a programmer to specify the type of filter (LPF, HPF, etc.) along with the defining characteristics (cut-off frequency, amplitude, etc.) and MATLAB produces an impulse response for the filter.
There are two functions that create feed-forward filters with a finite-length impulse response (FIR). To create standard filter shapes (LPF, HPF, BPF, notch), the function fir1 should be used. To create filters with any arbitrary amplitude response, the function fir2 should be used.
The following is the syntax for using fir1:
[h] = fir1(m,Wn,ftype)
Input Variables:
m – filter order, length of impulse response. Example: 10
Wn – normalized cut-off frequency. Example: 0.5
ftype – filter type. Example: 'low' , 'high' , 'bandpass' , 'stop'
Output Variable:
h – output impulse response.
The following is the syntax for using fir2:
[h] = fir2(m,[0,lowF,highF,1],[dcA,lowA,highA,nyqA])
Input Variables:
m – filter order, length of impulse response. Example: 10
lowF, highF – normalized cut-off frequencies.
dcA, lowA, highA, nyqA – linear amplitude for corresponding frequencies.
Output Variable:
h – output impulse response.

