0% found this document useful (0 votes)
72 views34 pages

DSP Journal - BE-08 PDF

The document describes experiments conducted to analyze discrete time signals using digital signal processing techniques. The experiments: 1. Generate and plot basic discrete time signals like impulse, step, ramp, exponential and sinusoidal. 2. Obtain the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of signals to analyze their frequency content. 3. Verify properties of DFT like periodicity, linearity, and use of convolution theorem through programs in Scilab/MATLAB. Fast Fourier transform (FFT) is used to efficiently compute DFT.

Uploaded by

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

DSP Journal - BE-08 PDF

The document describes experiments conducted to analyze discrete time signals using digital signal processing techniques. The experiments: 1. Generate and plot basic discrete time signals like impulse, step, ramp, exponential and sinusoidal. 2. Obtain the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of signals to analyze their frequency content. 3. Verify properties of DFT like periodicity, linearity, and use of convolution theorem through programs in Scilab/MATLAB. Fast Fourier transform (FFT) is used to efficiently compute DFT.

Uploaded by

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

Digital Signal Processing & Processor VI Semester

Experiment – 1: Generation and plotting of certain basic discrete time signals

Aim​:

To generate and plot several basic discrete time signals.

Software used:

Scilab / MATLAB

Theory:

Certain discrete time signals are most frequently encountered while studying digital signal
processing. Some of them are generated through software and plotted in this experiment. A brief
description of such signals is given below:

1. ​Unit Impulse

It is denoted as δ(n) in discrete time domain and can be defined as;

2. Unit Step Signal


Discrete time unit step signal is defined as;

.
3. Ramp signal
A discrete time ramp signal can be defined as ,

1
ELECTRONICS ENGINEERING DEPARTMENT Jatin Gohil (08)
Digital Signal Processing & Processor VI Semester

4. Exponential signal

Rising Exponential signal

x [n] = c.αn where α>1

Decaying Exponential Signal:

x [n] = c.αn where 0<α<1

2
ELECTRONICS ENGINEERING DEPARTMENT Jatin Gohil (08)
Digital Signal Processing & Processor VI Semester

5. Discrete sinusoidal signal


All continuous-time sinusoidal signals are periodic. The discrete-time sinusoidal sequences
may or may not be periodic. For a discrete time sinusoidal signal to be periodic, the angular
frequency ω must be a rational multiple of 2π.
Discrete form of a sinusoidal signal can be represented as.
x(n)=A sin (ωn+ϕ)

Algorithm & Procedure:

1) Enter the range of discrete time variable.


2) Write a program to generate and plot unit impulse and step function

3) Write function to generate and plot exponential signal


4) Write function to generate sinusoidal signal

Program:

n1​=​ ​-​5​:​5​ ​//range of values for n//


n​=​ ​0​:​20​ ​//range of values for n//
y1​=​{​zeros​(​1​,​5​)}​; ​//y axis=0 for negative values of n//

//plotting unit impulse//


y2​=​{​ones​(​0​)​,​zeros​(​1​,​5​)}​ ​//y axis=1 at 0, y axis=0 for positive values ofn//
y​=​[​y1,y2​]​ ​//concatinating y1,y2//
subplot​(​3​,​2​,​1​)
plot2d3​(​n1,y​'​)
xlabel​(​'n'​)​;
ylabel​(​'amplitude'​)​;
title​(​"Unit Impulse"​)

//plotting of Unit Step//


y3​=​[​ones​(​1​,​6​)]​; ​//y axis= 1 for positive values of n//
y4​=​[​y1,y3​]​; ​//concatinating y1,y3//

3
ELECTRONICS ENGINEERING DEPARTMENT Jatin Gohil (08)
Lab Manual Digital Signal Processing & Processor VI Semester

subplot​(​3​,​2​,​2​)
plot2d3​(​n1,y4​'​)
xlabel​(​'n'​)​;
ylabel​(​'amplitude'​)​;
title​(​"Unit Step"​)

//Plotting of Ramp//
x​=​1​:​10​ ​//Defining the range of x//
y5 ​=​x ​//Value of y axis= present value of x//
subplot​(​3​,​2​,​3​)
plot2d3​(​x,y5​'​)
xlabel​(​'n'​)​;
ylabel​(​'amplitude'​)​;
title​(​"Ramp"​)

//Plotting of rising exponential//


y7​=​exp​(​n​)​ ​//Using exponential command to plot the positive exponential of n//
subplot​(​3​,​2​,​4​)
plot2d3​(​n,y7​'​)
xlabel​(​'n'​)​;
ylabel​(​'amplitude'​)​;
title​(​"Rising Exponential"​)

//Plotting of decaying exponential//


y8​=​exp​(​-​n​)​ ​//Using exponential command to plot the negative exponential of n//
subplot​(​3​,​2​,​5​)
plot2d3​(​n,y8​'​)
xlabel​(​'n'​)​;
ylabel​(​'amplitude'​)​;
title​(​"Decaying Exponential"​)

//Plotting of Sine Wave//


f​=​0.05​ ​//Defining the value of frequency(max frequency=0.5)//
y9​=​sin​(​2​*​%pi​*​f​*​n​)​ ​//Formula for plotting a sine wave of a digital signal//
subplot​(​3​,​2​,​6​)
plot2d3​(​n,y9​'​)
xlabel​(​'n'​)​;
ylabel​(​'amplitude'​)​;
title​(​"Sine Wave"​)

Output Window

4
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Conclusion: ​Basic Discrete signal generated and plotted

Experiment - 2- Discrete Fourier Transform

5
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Aim:​ To obtain DFT and IDFT of a signal.

Software used:​:

Scilab, MATLAB

Theory
​DFT is widely employed in ​signal processing and related fields to analyze the
frequencies contained in a sampled ​signal​, to solve ​partial differential equations​, and to
perform other operations such as ​convolutions​. The DFT can be computed efficiently in
practice using a ​fast Fourier transform​ (FFT) algorithm.

DFT is a computational tool for performing frequency analysis of discrete time signals.
The mathematical expression is
N −1 −j2πkn
X (k) = ∑ x[n]e N ​ 0,1,2​,..........(N-1)
for ​k =
n=0

The inverse discrete Fourier transform (IDFT) is given by


N −1 j2πkn
1
x[n] = N
∑ X [k]e N for n = 0,1,2,......(N-1)
k=0

Algorithm & Procedure:

1)​ ​Enter the signal and value of N.

2) Write a formula to find DFT

3) Display the DFT output values

4) Write a formula to find IDFT

5) Generate the original signal by applying IDFT

Scilab Program:

N​=​input​(​"state the value of N"​)​ ​//State the value of N//


n​=​ ​0​:​N​-​1​; ​//n=0 to N-1//
k​=​n;
a​=​(​-​%i​*​2​*​%pi​*​k​'*​n​/​N​)​; ​//a= -j2pikn/N//
x​=​input​(​'discrete signal'​)​; ​//Give a discrete signal of your choice//
X​=​ x​*​exp​(​a​)​; ​//DFT of X//
disp​(​'X='​)​;
disp​(​X​)​;
a​=​(​%i​*​2​*​%pi​*​k​'*​n​/​N​)​; ​//a= +j2pikn?N//
6
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

x​=​1​/​N​*​X​*​exp​(​a​)​; ​//IDFT formula//


disp​(​'x='​)​;​//Original Discrete Signal
disp​(​x​)​;
Output Window:

state the value of N 8

1)​ discrete signal ​[1 2 3 4 5 6 7 8]

X=

36. - 4. + 9.6568542i - 4. + 4.i - 4. + 1.6568542i - 4. - 3.919D-15i - 4. - 1.6568542i - 4. - 4.i


- 4. - 9.6568542i

x=

1. - 6.661D-16i 2. + 2.665D-15i 3. - 4.479D-15i 4. - 4.330D-15i 5. - 2.220D-15i 6. +


1.554D-15i 7. + 6.199D-15i 8. - 1.998D-15i

2)​ discrete signal ​2^n

X=

255. 48.63961 + 166.06602i - 51. + 102.i - 78.63961 + 46.066017i - 85. - 7.666D-14i -


78.63961 - 46.066017i - 51. - 102.i 48.63961 - 166.06602i

x=

1. + 7.105D-15i 2. + 3.197D-14i 4. - 5.150D-14i 8. - 7.816D-14i 16. - 3.908D-14i 32. +


2.487D-14i 64. + 8.301D-14i 128. - 3.730D-14i

Conclusion : ​A Program is generated to find DFT & IDFT

Experiment – 3: Verification of Properties of DFT


7
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Aim​: Write a program to illustrate the application of FFT in calculation of DFT.

Software used:
Scilab/ MATLAB.

Theory

DFT is a computational tool for performing frequency analysis of discrete time


signals.

Properties of DFT:

● Periodicity

● Linearity

● convolution
If

Then

Procedure:

1. Enter the given signal


2. Apply the 'fft ' function to the signal.
3. Plot the output values.
4. Enter the another signal
5. Apply the 'ifft ' function to the signal.
6. Plot the output values.

8
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Scilab Program:
//Periodicity

N​=​input​(​"Define the value of N"​)​; ​//Define value of n//


n​=​ ​0​:​N​-​1​ ​//n= 0 to N-1//
k​=​n;
b​=​(​-​%i​*​2​*​%pi​*​k​'*​n​/​N​)​ ​//b= -j2pikn/N//
a​=​(​-​%i​*​2​*​%pi​*​k​'*​(​n​+​N​)​/​N​)​; ​//a= -j2pik(n+N)/N//
x​=​input​(​'discrete signal'​)​; ​//Give a discrete signal of your choice//
X​=​ x​*​exp​(​a​)​; ​//DFT of x(n+N)//
X1​=​ x​*​exp​(​b​)​; ​//DFT of x(n)//
disp​(​'X='​)
disp​(​X​)
disp​(​'X1='​)
disp​(​X1​)

//Linearity

N​=​input​(​"Define the value of N"​)​; ​//Define value of n//


n​=​ ​0​:​N​-​1​; ​//n= 0 to N-1//
k​=​n;
a​=​(​-​%i​*​2​*​%pi​*​k​'*​n​/​N​)​; ​//a= -j2pikn/N//
x1​=​input​(​'discrete signal'​)​; ​//x1= discrete signal 1//
x2​=​input​(​'discrete signal'​)​; ​//x2= discrete signal 2//
b​=​5​;
c​=​4​;
X1​=​ x1​*​exp​(​a​)​; ​//DFT of x1//
X2​=​ x2​*​exp​(​a​)​; ​//DFT of x2//
x​=​ b​*​x1​+​c​*​x2; ​//Multiply constants with x1, x2//
X​=​ x​*​exp​(​a​)​; ​//DFT of x//
disp​(​'X='​)
disp​(​X​)
Y​=​ b​*​X1 ​+​ c​*​X2; ​//Multiply X1,X2 with constants//
disp​(​'Y'​)
disp​(​Y​)​//To verify linearity property X=Y

//Convolution

x1​=​[​1​ ​2​ ​3​ ​0​]​//x1= discrete signal 1//


x2​=​[​1​ ​2​ ​0​ ​0​]​//x2= discrete signal 2//
X1​=​fft​(​x1​)​//DFT of x1//
X2​=​fft​(​x2​)​//DFT of x2//
X​=​X1​.*​X2
x​=​ifft​(​X​)
disp​(​'x='​)
disp​(​x​)
y​=​conv​(​x1,x2​)​//convolution of x1 and x2
disp​(​'y='​)
disp​(​y​)

9
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Output Window:

1) Periodicity Property
Define the value of N8

discrete signal[1 2 3 4 5 6 7 8]

X=
36. + 4.115D-14i - 4. + 9.6568542i - 4. + 4.i - 4. + 1.6568542i - 4. - 4.651D-15i - 4. -
1.6568542i - 4. - 4.i - 4. - 9.6568542i

X1=
36. - 4. + 9.6568542i - 4. + 4.i - 4. + 1.6568542i - 4. - 3.919D-15i - 4. - 1.6568542i - 4. - 4.i -
4. - 9.6568542i

2)​ ​Linearity

Define the value of N8

discrete signal[1 1 1 1 1 1 1 1]
discrete signal[1 2 3 4 5 6 7 8]

X=

184. - 16. + 38.627417i - 16. + 16.i - 16. + 6.627417i - 16. - 1.812D-14i - 16. - 6.627417i -
16. - 16.i - 16. - 38.627417i

Y
184. - 16. + 38.627417i - 16. + 16.i - 16. + 6.627417i - 16. - 1.812D-14i - 16. - 6.627417i -
16. - 16.i - 16. - 38.627417i

3) Convolution

x=
1. 4. 7. 6.

y=

1. 4. 7. 6. 0. 0. 0.

Conclusions: ​The fft and ifft of a signal is used to verify the properties of DFT.

Experiment – 4:
10
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Aim: ​To Write a program for finding the order of analog filter for a given set of specification using
Butterworth , Chebyshev approximation.

Requirements
Scilab/MATLAB

Theory: ​The ideal response of an IIR filter may be approximated using different response
functions. They are Butterworth , Chebyshev approximation. For a given set of filter
specification ,both of the approximations gives a different set of order of the filter. a
comparative study of filter behavior is carried out in this experiment by calculating the order
of individual filter for same set of specification.

Formula for finding order of Butterworth Filter:

log log √10


0.1αs −1
√100.1αp−1
N≥ Ωs
log log Ωp

Formula for finding order of Chebyshev Filter:


√100.1αs −1
√100.1αp−1
N≥ Ωs
Ωp

Procedure:
1) Enter the following filter specification
stop band frequency
pass band frequency
pass band ripple
stop band ripple
2) Use the formula for finding the order of filter using Butterworth and Chebyshev approximation
methods

3) Compare the order found by each method & comment on the same
4) Compare one of the specification keeping the other three constant observe the effect on order of
filter

Matlab Program:

11
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

clc;
Ws=input (​'Stop band frequency'​);​%stop band frequency
Wp=input(​'pass band frequency'​)​%pass band frequency
Ap=input (​'attenuation pass band'​);​%pass band ripple
As=input (​'attenuation stop band'​) ;​%stop band ripple

a=(10^(0.1*Ap))-1

b=(10^(0.1*As))-1
d=sqrt(b/a)
e=log(d)
f=log (Ws/Wp)
N=e/f
disp(​'N='​)
disp(round(N))
g=acosh(d)
h=acosh (Ws/Wp)
M=g/h
disp(​'M='​)
disp(round(M))
Wn=0.5
disp(​'The order of filter is'​);
disp(n);
disp(​'cut off frequencies'​);
disp(Wn);
[nums,dens] = butter(n,Wn)​%filter coefficient calculation
freqz(nums,dens),
title(​'magnitude and phase responses of Analog Lowpass Butterworthfilter'​);
figure
[nums1,dens1] = cheby1(n,Ap,0.6)
title(​'magnitude and phase responses of Analog Lowpass BChebyshev'​);
freqz(nums1,dens1)
figure

Ouput on Command Window

Stop band frequency1000


pass band frequency500

attenuation pass band3

attenuation stop band40

N=
7

M=

12
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

cut off frequencies


0.5000

nums =

0.0166 0.1160 0.3479 0.5798 0.5798 0.3479 0.1160 0.0166

dens =

1.0000 -0.0000 0.9200 -0.0000 0.1927 -0.0000 0.0077 -0.0000

nums1 =

0.0105 0.0734 0.2203 0.3672 0.3672 0.2203 0.0734 0.0105

dens1 =

1.0000 -0.6965 1.9570 -1.6421 1.6868 -1.2272 0.6094 -0.3444

Conclusion: ​For the given set of specification filter order and cut off frequency was calculated for
Butterworth ,Chebyshev.

13
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Experiment -5-A : IIR Filter design using Impulse Invarient method

Aim:​ To write a programe to design an IIR digital filter starting with digital specifications using
Impulse Invarient method.

Requirements
MATLAB

Theory:

Impulse Invarient Transformation

IIR filter design using impulse invariance is one of the IIR digital filter design techniques using
analog filter transfer function. In this method, the analog filter impulse response h(t) is found out
from the analog filter transfer function H a (s) . This impulse response is discretised by sampling it at
regular intervals of ts . Z-transform of these samples is taken to obtain H(z). Thus the impulse
response of the digital filter is same as that of analog filter at the sampling instants and hence the
name impulse invariance technique. This method maps a stable analog function into a stable digital
function. However, due to sampling the j Ω axis in the s plane is not mapped uniquely into the unit
radius circle in the Z plane. Hence , this technique is restricted and used to design only low pass
filters and band pass filters with low resonant frequencies.

Algorithm & Procedure:

1) Enter the following filter specification

stop band frequency


pass band frequency
pass band ripple
stop band ripple
sampling frequency

2) Design prototype analog filter


3) Convert to digital filter using impulse invarience method.

4) Plot frequency response.

5)Plot the pole zero plot.

Matlab Program:
% EXP 5-Program to design a IIR filter using Impulse Invariance Transformation.
clear ​all​;
clc;
% PART A
wp=input(​'Enter the pass band frequency'​);
ws=input(​'Enter the stop band frequency'​);

14
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Ap=input(​'Enter the pass band attenuation in dB'​);


As=input(​'Enter the stop band attenuation in dB'​);
fs=input(​'Enter Sampling Frequency'​);
wp1=(2*pi*wp)
ws1=(2*pi*ws)
%Calculating filter order
[N,wn]=buttord(wp1,ws1,Ap,As,​'s'​);
disp(​'The order of filter is'​);
disp(N);
disp(​'cut off frequencies'​);
disp(wn);
[n,d]=butter(N,wn,​'s'​);
sys=tf(n,d)
disp(​'transfer function of analog filter'​)
disp(sys)
[ni,di]=impinvar(n,d,fs)
sys1=tf(ni,di)
disp(sys1)
[h,f]=freqz(ni,di,512,fs);
subplot(2,2,1);
plot(f,abs(h));
title(​'frequency response of Filter'​)
%pole zero plot
subplot(2,2,2);
zplane(ni,di);
title(​'Z-Plane of Filter'​)

Enter the pass band frequency150


Enter the stop band frequency700
Enter the pass band attenuation in dB3
Enter the stop band attenuation in dB18
Enter Sampling Frequency3000

wp1 =

942.4778

ws1 =

4.3982e+03

The order of filter is


2

cut off frequencies


1.5668e+03

15
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

sys =

2.455e06
-----------------------
s^2 + 2216 s + 2.455e06

Output window:

Experiment -5-B: IIR Filter design using Bilinear Transformation Method:

Aim:​ To write a programe to design an IIR digital filter starting with digital specifications using
Bilinear Transform method.

Requirements
MATLAB

Bilinear Transformation Method:

This is yet another technique of obtaining the digital filter function from an analog filter function.
In this technique the analog differential equation representing the filter system is integrated using
the trapezoidal rule of integration. The s plane to Z plane mapping is obtained by taking the
Z-transform of the resulting difference equation.
Bilinear Transformation maps a stable analog filter function into a stable digital filter
function. Also, the entire j Ω axis in the s-plane ( − ∞ to + ∞ ) is mapped only once into the Z- plane
over the unit radius circle. Hence, it can be used to design all types of digital filters. However, the
transformation function given by Ω = ( 2t ) tan tan (w/2) is highly nonlinear and the frequencies at
the higher end in the analog domain are compressed in the digital domain. This effect is known as
frequency warping.

Algorithm & Procedure:

16
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

​1) Enter the following filter specification

stop band frequency


pass band frequency
pass band ripple
stop band ripple

sampling frequency

2) Apply frequency Pre warping.

3) Design prototype analog low pass filter.


4) Convert to digital filter using by bilinear transformation method.

5) Plot the frequency response.

6)Plot the pole zero plot.

Matlab Program:
Ws=(2*pi*ws)/(fs/2);
xp=tan(Wp/2);
xs=tan(Ws/2);
Fpb=(xp*fs)/(4*pi)
Fsb=(xs*fs)/(4*pi)
disp(Fpb);
disp(Fsb);
Wp1=(2*pi*Fpb);
Ws1=(2*pi*Fsb)
[N,wn]=buttord(Wp1,Ws1,Ap,As,​'s'​);
[n,d]=butter(N,wn,​'s'​);
[ni,di]=bilinear(n,d,fs)
sys1=tf(ni,di)
disp(sys1)
[h,f]=freqz(ni,di,1024,fs);
subplot(2,2,1);
plot(f,abs(h));
title(​'frequency response of Filter'​)
%pole zero plot
subplot(2,2,2);
zplane(ni,di);
title(​'Z-Plane of Filter'​)
Ouput on Command Window
Enter the pass band frequency150
Enter the stop band frequency700
Enter the pass band attenuation in dB3
Enter the stop band attenuation in dB18
Enter Sampling Frequency3000

Fpb =

17
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

77.5689

Fsb =

2.2714e+03

77.5689

2.2714e+03

Ws1 =

1.4272e+04

ni =

0.2319 0.2319

di =

1.0000 -0.5363

sys1 =

0.2319 s + 0.2319
-----------------
s - 0.5363

Output window:

18
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Conclusion:

It is verified that the bilinear transformation method is superior as compared to impulse invarient
method.

19
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Experiment – 6:

Aim: To d​esign of IIR Low pass and High Pass digital butterworth Filters and plot magnitude
response and pole zero diagram

Requirements
MATLAB

Theory:

Infinite Impulse Response (IIR) Filters: Another type of filter is the Infinite Impulse Response (IIR)
filter and the Impulse Response of an IIR filter is of infinite duration. The IIR filters have the
feedback, due to which they are also known as Recursive filters.

The general difference for an IIR filter is:


N −1 M −1
y(n)= - ∑ ak y (n − k ) + ∑ bk x(n − k )
k=1 k=0

Where ''a​k "​ is the k-th feedback tap.

N is the number of feedback taps in IIR filter and M is the number of feed forward taps

​ hy IIR Filters: IIR filters are usually used when computational resources are at a premium.
W
However, stable, causal IIR filters cannot have perfectly linear phase, so that IIR filters tend to be
avoided when linearity of phase is a requirement. Also, computational savings that are comparable
to using IIR filters can be achieved for certain design parameters by using multistage or multirate
FIR filter designs. These designs have the advantage of having linear-phase capability, robustness
to quantization, stability, and good pipeline-ability. Another important reason to use IIR filters is
their relatively small group delay compared to FIR filters. This results in a shorter transient
response to input stimuli. Even if we are able to match or surpass the implementation cost of an IIR
filter by using multirate or multistage FIR designs, the transient response of such FIR designs tends
to be much larger than that of a comparable IIR design. However, minimum-phase FIR design can
have group delays that are comparable or even lower than IIR filters that meet the same
specifications.

In this experiment, you will study the different methods of designing the Infinite Impulse Response
(IIR) Filters

Filters are a basic component of all signal processing and telecommunication system. A filter is a
device or process that removes some unwanted components or features from a signal. Filtering is a
class of signal processing used to complete or partial suppression of some aspects of the signal.
Most often, this means to remove some frequencies and not others in order to suppress the
interfacing signals and reduce the background noise.
20
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Types of Filters:
In signal processing, the filters can be of four types, i.e. Lowpass Filters, Highpass Filter, Bandpass
Filters, and Bandstop Filters.

Lowpass Filters:
An ideal Lowpass filter is the one that allows to pass all frequency components of a signal below a
designated cutoff frequency w​c​, and rejects to pass all frequency components of a signal above w​c
.Its frequency response satisfies.

H​LP​(e​jw​) = {1, 0≤ω≤ωc 0, ωc, < ω≤П

Highpass Filters:
An ideal Highpass filter is the one that allows to pass all frequencycomponents of a signal above a
designated cutoff frequency w​c​ , and rejects to pass all frequency components of a signal below
w​c
.Its frequency response satisfies

H​HP​(e​jw​) = {0, 0≤ω≤ωc 1, ωc, < ω≤П

Procedure:
1) Enter the following filter specification
stop band frequency
pass band frequency
pass band ripple
stop band ripple
2) Normalize the edge frequencies.

3) Find the order of Digital Butterworth filter

4) For the order, design Low pass and band High filter using MATLAB function

5) Plot the frequency response and pole zero diagram.

MATLAB Program:
clc;
clc;
Ws=input (​'Stop band frequency'​);​%stop band frequency

Wp=input(​'pass band frequency'​)​%pass band frequency


Ap=input (​'attenuation pass band'​);​%pass band ripple
As=input (​'attenuation stop band'​) ;​%stop band ripple

Fs=input(​'enter the sampling frequency'​);


%lowpass
[n,Wn]=buttord(Wp/Fs,Ws/Fs,Ap,As);
disp(​'order of the butterworth filter'​);
21
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

disp(​'n'​);
disp(n);
[b,a]=butter(n,Wn,​'low'​);
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,1);
plot(f,abs(h));
%pole zero plot
subplot(3,2,2);
zplane(b,a);
Wsh=input (​'Stop band frequency'​);​%stop band frequency

Wph=input(​'pass band frequency'​)​%pass band frequency


Aph=input (​'attenuation pass band'​);​%pass band ripple
Ash=input (​'attenuation stop band'​) ;​%stop band ripple

%highpass
[n,Wn]=buttord(Wph/Fs,Wsh/Fs,Aph,Ash);
disp(​'order of butterworth filter'​);
disp(​'n'​);
disp(n);
[b,a]=butter(n,Wn,​'high'​);
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,3);
plot(f,abs(h));
%pole zero plot
subplot(3,2,4);
zplane(b,a);

Output on Command Window:

Stop band frequency200

pass band frequency100

Wp =

100

attenuation pass band3

attenuation stop band18


enter the sampling frequency500
order of the butterworth filter

n
22
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

3
Stop band frequency300

pass band frequency100

Wph =

100
attenuation pass band3
attenuation stop band25

order of butterworth filter

n
2

Conclusion: ​Digital Butterworth Low pass and High pass filter are designed and characteristics are
plotted.

Experiment – 7:

23
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Aim: To d​esign of IIR Band pass and Band stop digital butterworth Filters and plot magnitude
response and pole zero diagram

Requirements
MATLAB

Theory

Bandpass Filters: An ideal Bandpass filter is the one that allows to pass all frequency components
of a signal within a certain range, and rejects to pass all frequency components of a signal outside
of that range. Its frequency response satisfies:

H​BP​(e​jw​) = {1, ωL≤w≤ωH 0, Otherwise

Bandstop Filters: An ideal Bandstop filter is the one that rejects to pass all frequency components
of a signal within a certain range, and allows to pass all frequency components of a signal outside
of that range. Its frequency response satisfies:

H​BS​(e​jw​) = {0, ωL≤w≤ωH 1, Otherwise

​ rocedure:
P
1) Enter the following filter specification

stop band frequency


pass band frequency
pass band ripple
stop band ripple

2) Normalize the edge frequencies.

3) Find the order of Digital Butterworth filter

4) For the order, design band pass and band stop filter using MATLAB function
5) Plot the frequency response and pole zero diagram.

MATLAB Program:
clc;
clc;
Wsl=input(​'Enter the lower stop band frequency'​)​%stop band frequency
Wsh=input(​'Enter the upper stop band frequency'​)​%stop band frequency
Wpl=input(​'Enter the lower pass band frequency'​)​%pass band frequency
Wph=input(​'Enter the upper pass band frequency'​)​%pass band frequency

Ap=input (​'attenuation pass band'​);​%pass band ripple


24
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

As=input (​'attenuation stop band'​) ;​%stop band ripple

Fs=input(​'enter the sampling frequency'​);


%Bandstop
Wp=[Wpl Wph]/Fs
Ws=[Wsl Wsh]/Fs
[n,Wn]=buttord(Wp,Ws,Ap,As);
disp(​'order of the butterworth filter'​);
disp(​'n'​);
disp(n);
[b,a]=butter(n,Wn,​'stop'​);
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,1);
plot(f,abs(h));
title(​'frequency response of Band Stop Filter'​)
%pole zero plot
subplot(3,2,2);
zplane(b,a);
title(​'Z-Plane of Band Stop Filter'​)

%Bandpass
Wsl1=input(​'Enter the lower stop band frequency'​)​%stop band frequency
Wsh1=input(​'Enter the upper stop band frequency'​)​%stop band frequency
Wpl1=input(​'Enter the lower pass band frequency'​)​%pass band frequency
Wph1=input(​'Enter the upper pass band frequency'​)​%pass band frequency
Ap=input (​'attenuation pass band'​);​%pass band ripple
As=input (​'attenuation stop band'​) ;​%stop band ripple
Wp1=[Wpl1 Wph1]/Fs
Ws1=[Wsl1 Wsh1]/Fs
[n,Wn]=buttord(Wp1,Ws1,Ap,As);
disp(​'order of butterworth filter'​);
disp(​'n'​);
disp(n);
[b,a]=butter(n,Wn);
%frequency plot
[h,f]=freqz(b,a,1024,Fs);
subplot(3,2,3);
plot(f,abs(h));
title(​'frequency response of Band Pass Filter'​)
%pole zero plot
subplot(3,2,4);
zplane(b,a);
title(​'Z-Plane of Band Pass Filter'​)

Output on Command Window:

Enter the lower stop band frequency75

25
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Wsl =

75

Enter the upper stop band frequency175

Wsh =

175

Enter the lower pass band frequency100

Wpl =

100

Enter the upper pass band frequency150

Wph =

150

attenuation pass band3

attenuation stop band18

enter the sampling frequency500

Wp =

0.2000 0.3000

Ws =

0.1500 0.3500

order of the butterworth filter

Passband

Enter the lower stop band frequency100

Wsl1 =

100

Enter the upper stop band frequency150


26
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

Wsh1 =

150

Enter the lower pass band frequency75

Wpl1 =

75

Enter the upper pass band frequency175

Wph1 =

175

attenuation pass band3

attenuation stop band18

order of the butterworth filter

Experiment – 8: Analysis of Linear Phase FIR Filter

Aim: ​To write a program

27
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

1) To check the linear phase condition and classify the given filter into type I, II, III,IV based
on the impulse response.
2) To study the magnitude and phase response of the filter.

Requirements

MATLAB.

Theory: ​The filter is supposed to operate with a defined pass band and a stop band. An ideal filter
must have constant gain and uniform delay for all the frequencies in pass band. The group delay is
the derivative of the phase angle with respect to frequency. That is,

Group Delay, τ p = dθ(ω)/d(ω)

where ω is the frequency and θ(ω) is the corresponding phase angle.


The group delay becomes constant with respect to frequency if the phase angle happens to be linear
function of the frequency. Hence linear phase filter can have uniform group delay. Linear phase
property is exhibited only by FIR filters. An FIR filter has linear phase if its impulse response is
either symmetric or anti symmetric. The nature of the pass band depends on the filter length and its
symmetry as shown in the table below.

Filter Length and Symmetry Type Nature of pass bands


Symmetric with odd length I LP, HP, BP and BS
Symmetric with even length II LP and BP
Anti symmetric with odd length III BP
Anti symmetric with even length IV HP and BP
The magnitude and phase response along with zero location of such filters are investigated through
a program.

Algorithm & Procedure:

1) Enter the impulse response sequence.


2) Check the symmetry, anti symmetry, even and odd length of the filter impulse response.
3) As per the linear phase property classify it into any one of the four types of linear phase FIR
filter.
4) Plot pole-zero, magnitude and phase plots of the FIR filter and comment on the same.
5) Plot impulse response.
6) Explain the functions used.

Matlab Program:
clc;
close ​all​;

28
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

clear ​all​;
hn=input(​'Input the impulse response seuence h(n)'​);​%Get impulse response from user
N=length(hn) ​% order of the filter
%find out Symmetry of filter
hf=fliplr(hn);
if​(hn==hf)
ANS1=0;
disp(​'symmetric'​)
elseif​(hn==-hf)
ANS1=1;
disp(​'Asymmetric'​)
else
ANS1=2;
disp(​'Not a valid Linear phase filter'​)
end

%find out whether filter is even or odd


if​ rem(N,2)==0
disp(​'even'​);
ANS2=1;
else
disp(​'odd'​);
ANS2=0;
end
%find out Type of filter
if​ ((ANS1==1)&& (ANS2==0));
Type=1
elseif​ ((ANS1==1)&& (ANS2==1));
Type=2
​elseif​ ((ANS1==0)&& (ANS2==0));
Type=3
elseif​ ((ANS1==0)&& (ANS2==1));
Type=4
else
disp(​'Not a valid Linear phase filter'​)
Type=0
end
disp(​'Given transfer function'​)
Hz=tf(hn,[1],0.1,​'variable'​,​'z^-1'​)​% Create transfer function in the form of num/den
disp(​'poles and zeros of given transfer function is'​)
[p z]=pzmap(Hz)
subplot(221)
zplane(z,p)
xlabel(​'real axis'​);
ylabel(​'imaginary axis'​);
title([​'poles and zeros plot in z-plane for Type'​ int2str(Type)]);
[Hf,w]=freqz(hn,1);
subplot(222)
plot(w,Hf);
xlabel(​'frequency'​);
29
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

ylabel(​'Amplitude'​);
title(​'Frequency responce'​);
subplot(223)
plot(w,abs(Hf));
xlabel(​'frequency'​);
ylabel(​'Amplitude'​);
title(​'Magnitude responce'​);
subplot(224)
plot(w,angle(Hf));
xlabel(​'frequency'​);
ylabel(​'phase'​);
title(​'Phanse responce'​);

Output on Command Window:

Input the impulse response seuence h(n)[1/12 1/6 1/6 -1/6 -1/6 -1/12]

hn =

Columns 1 through 6

0.0833 0.1667 0.1667 -0.1667 -0.1667 -0.0833

N=

Asymmetric

even

Type =

Transfer function:

0.08333 + 0.1667 z^-1 + 0.1667 z^-2 - 0.1667 z^-3 - 0.1667 z^-4 - 0.08333 z^-5

poles and zeros of given transfer function is

p=

0 0 0 0 0

z=

-1.1217 + 1.3066i -1.1217 - 1.3066i 1.0000 -0.3783 + 0.4406i -0.3783 - 0.4406i

30
ELECTRONICS ENGINEERING Department
Lab Manual Digital Signal Processing & Processor VI Semester

ELECTRONICS ENGINEERING DEPARTMENT Page | 31


Lab Manual Digital Signal Processing & Processor VI Semester

EXPERIMENT -9: Finite Impulse Response (FIR) filter design using Window Technique

Aim:​ Write a Program to design an FIR low pass filter using window function.

Requirements​: MATLAB.

​ indowing technique is one of the methods used for FIR filter design. An ideal filter
W
function in the frequency domain gives infinitely stretched response in the time domain. This
response is made finite by multiplying it with suitable window function. The response is made
causal by shifting the required number of samples towards right. There are different window
functions along with the corresponding frequency response is studied in this experiment.

FIR Window Functions:


m=filter length
Rectangular Window:
w(n)=1 for n=0 to m-1

Hamming Window:
w(n)=0.54+0.46*cos(2*pi*n/(m-1)) for n=0 to m-1
Hanning Window:
w(n)=0.5+0.5*cos(2*pi*n/(m-1)) for n=0 to m-1
Blackman Window:
w(n)=0.42+0.5*cos(2*pi*n/(m-1))+0.08*cos(4*pi*n/(m-1)) for n=0 to m-1

Algorithm & Procedure:

1) Enter the length of the filter.


2) Compute w(n) for different window functions using respective formulas.
3) Compute the frequency response for these window functions.
4) Use MATLAB commands to view the window functions for Rectangular, Hanning,
Hamming and Blackman in time and frequency domain.
5) Plot the time and frequency domain behavior of all the available window functions for FIR
filter design.

MATLAB Program:
clc;
M=input(​'enter the length of the filter='​);
disp(M);
n=( (-(M-1)/2)) : 1 :((M-1)/2);
wa=0:0.1:pi;
fc=0.5;
%rectangular window
w=[ones(1,M)];

ELECTRONICS ENGINEERING DEPARTMENT Page | 32


Lab Manual Digital Signal Processing & Processor VI Semester

subplot(4,3,1);
stem(n,w)
title(​'Rectangular Window'​)
W=freqz(w,1,wa);
subplot(4,3,2);
plot(wa,abs(W))
h=fir1(M-1,fc,w);
H=freqz(h,1,wa);
subplot(4,3,3);
plot(wa,abs(H));

%hamming window
w1=0.54+(0.46*cos(2*pi*n/(M-1)));
subplot(4,3,4)
stem(n,w1);
title(​'Hamming Window'​)
W1=freqz(w1,1,wa);
subplot(4,3,5)
plot(wa,abs(W1));
h=fir1(M-1,fc,w1);
H=freqz(h,1,wa);
subplot(4,3,6);
plot(wa,abs(H));

%hanning window
w2=0.5+0.5*cos(2*pi*n/(M-1));
subplot(4,3,7)
stem(n,w2);
title(​'Hanning Window'​)
W2=freqz(w2,1,wa);
subplot(4,3,8)
plot(wa,abs(W2));
h=fir1(M-1,fc,w2);
H=freqz(h,1,wa);
subplot(4,3,9);
plot(wa,abs(H));

%blackman window
w3=0.42+0.5*cos((2*pi*n)/(M-1))+0.08*cos((4*pi*n)/(M-1));
subplot(4,3,10)
stem(n,w3);
title(​'Blackman Window'​)
W3=freqz(w3,1,wa);
subplot(4,3,11)
plot(wa,abs(W3));
h=fir1(M-1,fc,w3);
H=freqz(h,1,wa);
subplot(4,3,12);
plot(wa,abs(H));

ELECTRONICS ENGINEERING DEPARTMENT Page | 33


Lab Manual Digital Signal Processing & Processor VI Semester

Enter the length of the filter=21

ELECTRONICS ENGINEERING DEPARTMENT Page | 34

You might also like