Bandpass Filter Design: IIR and FIR in MATLAB

Before performing the experiment, first learn about the basic terms 

related to the experiments.

Z-Transform: Z transform is used to convert discrete time domain signal into discrete frequency domain signal. It has wide range of applications in mathematics and digital signal processing. It is mainly used to analyze and process digital data. Fourier transforms are for converting/representing a time-varying function in the frequency domain.

A Laplace transform are for converting/representing a time-varying function in the "integral domain". Z-transforms are very similar to Laplace but are discrete time-interval conversions, closer for digital implementations.

 

Bandpass Filter: A band-pass filter (BPF) is a filter that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range.

Filters have a variety of applications in data acquisition and analysis. They are used to alter the frequency content of a time signal by either reducing or amplifying certain frequencies.

Filters are used in different ways, from signal cleanup to analysis.

In some applications, filters are used to condition a time domain signal by attenuating unwanted frequency content. Examples include:

Anti-Aliasing Filter  An anti-aliasing filter is used to remove signal content that cannot be properly digitized before Analog-to-Digital conversion.
Noise Removal Filters could be used to remove unwanted high frequency noise from a signal, for example, a hiss in a musical recording.
Drift RemovalDrift or large offsets can be removed from a signal via a high pass filter or AC coupling.

Type of Filter:

High Pass – High pass filter is used to remove low frequency offsets from a signal. For example, if interested in only the dynamic content of a strain gauge signal, any low frequency drift in a gauge could be removed with a high pass filter.
Low Pass - A low pass filter attenuates, or gets rid of, frequencies above a specified frequency. For example, this could be used to remove high frequency hiss from an audio recording.
Band Pass – This filter is used to allow only a band limited portion of the frequency content to be passed through the filter.
Band Stop – A band stop filter is used to remove frequency content over a specified range.


Fig. 1 Type of Filters

There are two classes of digital filters are Finite Impulse Response (FIR) and Infinite Impulse Response (IIR).

Key Features of FIR and IIR Filter:

FIR stands for Finite Impulse Response filters, whereas IIR stands for Infinite Impulse Response filters. IIR and FIR filters are utilized for filtration in digital systems. FIR filters are more widely in use, because they differ in response.

 FIR filters have only numerators when compared to IIR filters, which have both numerators and denominators. Where the system response is infinite, we use IIR filters, and where the system response is zero, we use FIR filters. FIR filters are also preferred over IIR filters because they have a linear phase response and are non-recursive, whereas IIR filters are recursive, and feedback is also involved. FIR cannot simulate analog filter responses, but IIR is designed to do that accurately. IIR’s impulse response when compared to FIR is infinite.

The high computational efficiency of IIR filters, with short delays, often make the IIR popular as an alternative. FIR filters have become too long in digital feedback systems, as well as in other applications, and cause problems.


For the function used in source code, I would recommend to read from the Documentation help section of MATLAB 2021 Simulator. There, you will find all the documentation, example and formula used along with the references.

 

Experiment: 03


Aim:
Find the inverse z-transform of the following:


 %Source Code

clc;

clear all;

sos=[1 -1.22346 1 1 -1.433509 0;

     1 -0.437833 1 1 -1.293601 0.556929;

     1 1 0 1 -0.612159 0 ];

[numerator, denominator]=sos2tf(sos);

n=length(numerator);

m=length(denominator);

[Residues, Poles, direct_terms]=residue(numerator, denominator);

number_of_poles=length(Poles);

for i=1:10

sum=0;

j=1;

while j<=number_of_poles

sum=Residues(j)*Poles(j)^(i-1)+sum;

j=j+1;

end

h(i)=sum;

end

Output:

Residues =

   8.6172 + 0.0000i

   3.9507 + 2.6892i

   3.9507 - 2.6892i

 -15.8869 + 0.0000i

   2.0461 + 0.0000i

Poles =

   1.4335 + 0.0000i

   0.6468 + 0.3723i

   0.6468 - 0.3723i

   0.6122 + 0.0000i

   0.0000 + 0.0000i

direct_terms =     1

h =    2.6780    5.7361   11.3752   19.5181   31.4948   48.5906 72.5687 106.1360 153.4080 220.4651

 

 

Experiment: 04


Aim: A linear phase band Pass Filter is used to obtain following

specifications:

          Passband: 12-16 KHz,
       Transition width: 2 KHz,
         Passband Ripple: 1 dB,
 Stopband attenuation: 45 dB,
 Sampling frequency: 50 KHz.

%Source Code

clc;

close all;

clear;

rp=1;

rs=45;

fs=50000;

f=[10000 12000 16000 18000];

a=[0 1 0];

res=[10^(-rs/20) (10^(rp/20)-1)/(10^(rp/20)+1) 10^(-rs/20)];

[n, fo, ao, w]=firpmord(f,a,res,fs);

b=firpm(n,fo,ao,w);

freqz(b);

 

Output:

 

         Fig. 2 Linear Bandpass filter

 

                        Experiment: 05


Aim:
Design an IIR filter with the following specifications:
Lower Passband: 12-16 Hz
Upper pass band:450 – 500 Hz
Stop band: 200 – 300 Hz
Passband ripple: 3dB
Stopband Attenuation: 20dB
Sampling frequency: 1KHz

%Source Code

clc;

rp=3;

rs=20;

fs=1000;                  % sampling frequency

wp=[50 450]/(fs/2); % normalizing passband frequency

ws=[200 300]/(fs/2);       % normalizing stopband frequency

[n, wn]=buttord(wp,ws,rp,rs);

[b, a]=butter(n,wn,'stop');

[h, d]=freqz(b,a,128,fs);

subplot(2,1,1);

plot(d, abs(h));

g=angle(h);

subplot(2,1,2);

plot(d, g);

 

Output:

 

Fig. 3 IIR Filter Design

 

 

Experiment - 6

Aim: Implement the above filters using simulink and verify the performance.


Fig. 4 Bandpass Filter Design


                       Fig. 5 Design parameters of Bandpass Filter.


Hope! you like the content of the blogs and gain something from the post. Please give your valuable feedback in the comment section.

 <<<<DSP Experiments: Linear and Circular Convolution in MATLAB>>>>>>>

Post a Comment

0 Comments