0% found this document useful (0 votes)
62 views88 pages

Digital Signal Processing Lab Manual

Uploaded by

philwaren515
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)
62 views88 pages

Digital Signal Processing Lab Manual

Uploaded by

philwaren515
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/ 88

SWAMI KESHVANAND INSTITUTE OF TECHNOLOGY,

MANAGEMENT& GRAMOTHAN, JAIPUR

ECL-17

LABORATORY MANUAL

COURSE NAME- DIGITAL SIGNAL PROCESSING LAB

COURSE CODE- 5EC22

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


Digital Signal Processing Lab

TABLE OF CONTENTS

S.NO. CONTENTS

1 Vision, Mission, Quality policy of Institute

2. Vision, Mission of Department

3. PEO,PO,PSO,CO

4 CO-PO,PSO Mapping

5 RTU Syllabus

6 List of Experiments

7 Beyond Curriculum experiment and their mapping with PO, PSO

8 Do’s & Don’ts

9 Safety Measures

10 Introduction: Objective, scope and outcome of the course

Design continuous and discrete elementary signals (impulse, unit step,


Exp1
ramp) using mathematical expression.
Perform basic operations on signals like adding and subtracting, shifting
Exp:2
and scaling
Perform Continuous and discrete time Convolution (using basic
Exp:3
definition).
Exp:4 Checking Linearity and Time variance property of a system using
convolution, shifting.
Exp:5 To find DFT / IDFT of given DT signal.

Exp:7 N-point FFT algorithm

Exp:8 To implement Circular convolution

Department of ECE Page 2


Digital Signal Processing Lab

Exp:9 MATLAB code for implementing z-transform and inverse z-transform.

Perform inverse z-transform using residuez MATLAB function.


Exp:10

Exp:11 MATLAB program to find frequency response of analog LP/HP filters.

Exp:12 To design FIR filter (LP/HP) using windowing (rectangular, triangular,


Kaiser) technique using simulink.
Exp:13 To generate amplitude modulated signal for specific modulation index
and plot the spectrum.

Exp:14 To develop program for auto correlation and cross correlation

Department of ECE Page 3


Digital Signal Processing Lab

VISION, MISION QUALITY POLICY OF INSTITUTE

VISION OF INSTITUTE
To promote higher learning in advanced technology and industrial research to make our
country a global player

MISSION OF INSTITUTE
To promote quality education, training and research in the field of Engineering by
establishing effective interface with industry and to encourage faculty to undertake industry
sponsored projects for students

QUALITY POLICY OF INSTITUTE


We are committed to ‘achievement of quality’ as an integral part of our institutional policy by
continuous self-evaluation and striving to improve ourselves.

Institute would pursue quality in


• All its endeavors like admissions, teaching- learning processes, examinations, extra and co-
curricular activities, industry institution interaction, research & development, continuing
education, and consultancy.

• Functional areas like teaching departments, Training & Placement Cell, library,
administrative office, accounts office, hostels, canteen, security services, transport,
maintenance section and all other services.”

Department of ECE Page 4


Digital Signal Processing Lab

VISION, MISSION OF DEPARTMENT

VISION
“To evolve the department as a center of excellence in the field of electronics and
communication engineering for enriched education, higher learning, research and
development.”

MISSION
“To empower students by imparting quality education in electronics and communication
engineering for better employability and preparing them to be competent in dealing with
industrial and societal challenges.”

Department of ECE Page 5


Digital Signal Processing Lab

PROGRAM EDUCATIONAL OBJECTIVES


I. The graduates will be able to pursue their career successfully in the field of
Electronics & Communication Engineering and advance in their profession.
II. The graduates will be able to excel in pursuing higher education and life-long learning.
III. Graduates will be able to hold high ethical standards and work effectively in
multidisciplinary teams with strong management and team work skills.

PROGRAM OUTCOMES

The student will be able to


1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and mechanical engineering specialization to the solution of
complex engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze


complex engineering problems reaching substantiated conclusions using first principles
of mathematics, natural sciences, and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional


engineering solutions in societal and environmental contexts, and demonstrate the

Department of ECE Page 6


Digital Signal Processing Lab

knowledge of, and need for sustainable development.


8. Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member


or leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with


the engineering community and with society at large, such as, being able to comprehend
and write effective reports and design documentation, make effective presentations, and
give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of
the engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.

PROGRAM SPECIFIC OUTCOMES (PSOs)


The student will be able to

1. Understand principles and applications of electronic components, circuits and devices.


2. Develop proficiency in electronics and communication engineering to enhance
employability skills.

Department of ECE Page 7


Digital Signal Processing Lab

Course Outcomes :
After completion of this lab course, students will be able to -

C5EC22.1 Understand the mathematical operation on discrete signals.

C5EC22.2 Sketch the magnitude and phase response of DFT, Inverse DFT and FFT of
discrete time signals.

C5EC22.3 Calculate linear and circular convolution of discrete sequences.

C5EC22.4 Implement Z transform and inverse Z transform of discrete signals


C5EC22.5 Model IIR and FIR filter using window techniques

Department of ECE Page 8


Digital Signal Processing Lab

CO-PO, PSO MAPPING


CO-PO/PSO Mapping
CO P PO PO PO PO PO PO PO PO PO PO P
O 2 3 4 5 6 7 8 9 10 11 O1
1 2
C5EC22.1 3 2 1 2 2 - - - - 3 - 3

C5EC22.2 3 2 1 2 2 - - - - 3 - 3

C5EC22.3 3 2 1 2 2 - - - - 3 - 3

C5EC22.4 3 2 1 2 2 - - - - 3 - 3

C5EC22.5 3 3 1 3 2 - - - - 3 - 3

C5EC22 3 3 1 3 2 - - - - 3 - 3

CO-PSO Mapping

CO PSO1 PSO2

C5EC22.1 3 3

C5EC22.2 3 3

C5EC22.3 3 3

C5EC22.4 3 3

C5EC22.5 3 3

Department of ECE Page 9


Digital Signal Processing Lab

RTU SYLLABUS

5EC4-22: Digital Signal Processing Lab

Credit: 1.5 Max. Marks: 75(IA:45, ETE:30)


0L+0T+3P End Term Exam: 2 Hours
SN Contents
1 Introduction: Objective, scope and outcome of the course.
2 Generation of continuous and discrete elementary signals (impulse,unit-
step,ramp) using mathematical expression.
3 Perform basic operations on signals like adding, subtracting, shifting and
scaling.
4 Perform continuous and discrete time Convolution (using basic definition).
5 Checking Linearity and Time variance property of a system using
convolution, shifting.
6 To generate and verify random sequences with arbitrary distributions,
means and variances for

following:

(a) Rayleigh distribution

(b) Normal distributions: N(0,1).

(c) Gaussion distributions: N (m, x)

(d)Random binary wave.


7 To find DFT / IDFT of given DT signal.
8 N-point FFT algorithm.
9 To implement Circular convolution.
10 MATLAB code for implementing z-transform and inverse z-transform.
11 Perform inverse z-transform using residuez MATLAB function.
12 MATLAB program to find frequency response of analog LP/HP filters.
13 To design FIR filter (LP/HP) using windowing (rectangular, triangular,
Kaiser) technique using simulink.

Department of ECE Page 10


Digital Signal Processing Lab

LIST OF EXPERIMENTS

Exp. NO. List of Experiments

Design continuous and discrete elementary signals (impulse, unit step,


Exp:1
ramp) using mathematical expression.
Perform basic operations on signals like adding and subtracting,
Exp:2
shifting and scaling
Perform Continuous and discrete time Convolution (using basic
Exp:3
definition).
Exp:4 Checking Linearity and Time variance property of a system using
convolution, shifting.
Exp:5 To find DFT / IDFT of given DT signal.

Exp:7 N-point FFT algorithm

Exp:8 To implement Circular convolution

Exp:9 MATLAB code for implementing z-transform and inverse z-


transform.

Exp:10 Perform inverse z-transform using residuez MATLAB function.

MATLAB program to find frequency response of analog LP/HP


Exp:11
filters.
Exp:12 To design FIR filter (LP/HP) using windowing (rectangular,
triangular, Kaiser) technique using simulink.
Beyond Curriculum

Exp:13 To generate amplitude modulated signal for specific modulation index


and plot the spectrum.

Exp:14 To develop program for auto correlation and cross correlation

Department of ECE Page 11


Digital Signal Processing Lab

BEYOND CURRICULUM EXPERIMENT AND THEIR


MAPPING WITH PO, PSO
Beyond Curriculum Topics: With the topics in the syllabus the following topics will be
covered in this subject which are important for Signal Processing lab:

Experiment Beyond Syllabus topic Source


To generate amplitude modulated signal MATLAB
5EC22A.a for specific modulation index and plot
the spectrum.
To develop program for auto correlation MATLAB
5EC22A.b
and cross correlation

Mapping of beyond RTU syllabus Experiments with POs/PSOs:

Beyond
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
syllabus
5EC22A.a 3 3 3 - 3 3 - - - - - 3

3 3 3 3 - - - - - - - 3
5EC22A.b

Mapping of beyond RTU syllabus Experiments with PSOs:

Beyond syllabus PSO1 PSO2


5EC10A.a 3 3
5EC10A.b 3 3

Department of ECE Page 12


Digital Signal Processing Lab

INSTRUCTIONS OF LAB

DO’S

1. Student should get the record of previous experiment checked before starting the new
experiment.
2. Read the manual carefully before starting the experiment.
3. Before starting the experiment, system checked by the teacher.
4. Get your readings checked by the teacher.
5. Apparatus must be handled carefully.
6. Maintain strict discipline.
7. Keep your mobile phone switched off or in vibration mode.
8. Students should get the experiment allotted for next turn, before leaving the lab.

DON’TS

1. Do not touch or attempt to touch the mains power supply wire with bare hands.
2. Do not overcrowd the tables.
3. Do not tamper with equipments.
4. Do not leave the lab without permission from the teacher.

Department of ECE Page 13


Digital Signal Processing Lab

SAFETY MEASURES
1. Antivirus software is installed for protection against viruses and malwares.
2. External storage devices are not allowed to use in lab.
3. At all the times the right procedures while starting and shutting down the computer
therefore abrupt switching on and off the computer should be avoided since this can
lead to damaging the computer.
4. Any repairs to the computer should be done by someone who has knowledge
regarding computer repairs.

Department of ECE Page 14


Digital Signal Processing Lab

INTRODUCTION TO SCILAB

Scilab is a programming language associated with a rich collection of numerical algorithms


covering many aspects of scientific computing problems.
From the software point of view, Scilab is an interpreted language. This generally allows to
get faster development processes, because the user directly accesses to a high level language,
with a rich set of features provided by the library. The Scilab language is meant to be
extended so that user-defined data types can be defined with possibly overloaded operations.
Scilab users can develop their own module so that they can solve their particular problems.
The Scilab language allows to dynamically compile and link other languages such as Fortran
and C: this way, external libraries can be used as if they were a part of Scilab built-in features.
Scilab also interfaces LabVIEW, a platform and development environment for a visual
programming language from National Instruments.
From the license point of view, Scilab is a free software in the sense that the user does not
pay for it and Scilab is an open source software, provided under the Cecill license .The
software is distributed with source code, so that the user has an access to Scilab most internal
aspects. Most of the time, the user downloads and installs, a binary version of Scilab since the
Scilab consortium provides Windows, Linux and Mac OS executable versions. An online help
is provided in many local languages.
From a scientific point of view, Scilab comes with many features. At the very beginning of
Scilab, features were focused on linear algebra. But, rapidly, the number of features extended
to cover many areas of scientific computing. The following is a short list of its capabilities:
• Linear algebra, sparse matrices,
• Polynomials and rational functions,
• Interpolation, approximation,
• Linear, quadratic and non linear optimization,
• Ordinary Differential Equation solver and Differential Algebraic Equations solver,
• Classic and robust control, Linear Matrix Inequality optimization,
• Differentiable and non-differentiable optimization,
• Signal processing,
• Statistics.
Scilab provides many graphics features, including a set of plotting functions, which allow to
create 2D and 3D plots as well as user interfaces. The Xcos environment provides an hybrid
dynamic systems modeler and simulator.

OBJECTIVE OF LAB:

It is important to understand the processing of signals. Processing of signals means make


suitable form of signal/information according to the need or application. This can be done
with the help of filter, converter, multiplier, amplifiers etc. “Digital Signal Processing” is the
part of this signal processing in which the signal is processed in the digital domain or we can

Department of ECE Page 15


Digital Signal Processing Lab

say that in 0 and 1 form. This makes the processing fast and immune to the noise. Digital
Signal Processors (DSP) take real-world signals like voice, audio, video, temperature, pressure, or
positions that have been digitized and then mathematically manipulate them. A DSP is designed for
performing mathematical functions like "add", "Subtract", "multiply" and "divide" very quickly.
Signals need to be processed so that the information that they contain can be displayed, analyzed, or
converted to another type of signal that may be of use. In the real-world, analog products detect
signals such as sound, light, temperature or pressure and manipulate them. Converters such as an
Analog-to-Digital converter then take the real-world signal and turn it into the digital format of 1's and
0's. From here, the DSP takes over by capturing the digitized information and processing it. It then
feeds the digitized information back for use in the real world. It does this in one of two ways, either
digitally or in an analog format by going through a Digital-to-Analog converter. All of this occurs at
very high speeds.

This lab will teach the basics concepts involve in the digital processing of signals. It includes
many different topics, such as:

• filters
• analysis of signals and systems
• synthesis of signals
• Behavior of LTI systems
• Random sequence like Rayleigh distribution, Gaussian distribution etc.

SCOPE:

In the UG level projects one can design the system by applying the knowledge of DSP. This lab helps
to understand all the conditions of processing the signal.

Also in higher studies, the dissertation work includes the area of digital signal processing and image
processing speech processing, FPGA programming etc. so strong knowledge of DSP is needed.

Once the basic DSP background is in place, many application-specific DSP areas are
accessible. This includes speech processing (recognition, synthesis, and compression), image
processing, audio processing (analysis, synthesis, etc.), and all types of biomedical signal
processing, and on and on.

ADVANTAGES OF DSP :

The advantages of DSP over Analog Signal Processing are:

1. High Accuracy: The accuracy of the analog filter is affected by the tolerance of the circuit
components used for designing the filter, but DSP has superior control of accuracy.

2. Cheaper: The digital realization is much cheaper than the analog realization in many applications.

3. Flexibility in Configuration: For reconfiguring an analog system, we can only do it by redesign of


system hardware; where as a DSP System can be easily reconfigured only by changing the program.

4. Ease of Data Storage


Department of ECE Page 16
Digital Signal Processing Lab

5. Time Sharing: The cost of the processing signal can be reduced in DSP by the sharing of a given
processor among a number of signals.

APPLICATIONS OF DSP : DSP can be applicable in variety of fields such as

1. Telecommunication

2. Consumer Electronics

3. Image Processing

4. Instrumentation and Control

5. Military Applications

6. Speech Processing

7. Seismology

8. Medicine

LEARNING OBJECTIVES:

The student will be able to:


1. Generate elementary signals/ waveforms and perform arithmetic operations on signals.
2. Calculate and plot DFT / IDFT of given DT signal.
3. Plot frequency response of a given system and verify the properties of LTI system.
4. Implement FFT of given sequence.
5. Implement LP FIR filter for a given sequence and calculate the filter coefficients.
6. Implement HP FIR filter for a given sequence and plot the response of the same.
7. Generate amplitude modulated signal.
8. Find correlation between given sequences.
9. Implement convolution
10. Generate the random signals having different distributions, mean and variance.

Department of ECE Page 17


Digital Signal Processing Lab

EXPERIMENT NO: 1

AIM: To generate continuous and discrete time unit Impulse, unit step and unit ramp
signals using mathematical expressions

SOFTWARE USED: Scilab 6.1.0

THEORY: A unit step signal has magnitude 1 for time greater than or equal to zero. We can
assume it as a dc signal which got switched on at time equal to zero. Unit step signal is a basic
signal and is denoted by u (t) or u(n). This function is defined as.

Continuous time unit step signal

Figure 1.1: Continuous time unit step signal

Discrete time unit step signal

Figure 1.2: Discrete time unit step signal

Ramp signal: A ramp signal is a signal whose magnitude increases along with time. It can
be obtained by integrating unit step signal.

Department of ECE Page 18


Digital Signal Processing Lab

Continuous time Ramp Signal

Figure 1.3: Continuous time Ramp signal

Discrete time Ramp Signal

Figure 1.4: Discrete time Ramp signal

Impulse Signal: An ideal impulse function is a function that is zero everywhere except
origin, and at origin it is infinitely high. The unit impulse function has zero width, infinite
height and area under the curve is unity.

Figure 1.5: Continuous time Impulse signal

Department of ECE Page 19


Digital Signal Processing Lab

PROGRAM:

clc;
clear;

//for discrete time unit impluse signal//


n=input ('enter n=');
for i=1 :length(n)
if n(i)==0
y(i)=1;
else y(i)=0;
end
end
subplot (2,3,1)
plot2d3 (n,y)
xlabel("Time")
ylabel("Amplitude")

//for discrete time unit step signal//


for i=1 :length(n)
if n(i)>=0
u(i)=1;
else u(i)=0;
end
end
subplot (2,3,2)
plot2d3 (n,u)
xlabel("Time")
ylabel("Amplitude")

//for discrete time unit ramp signal//


for i=1 :length(n)
if n(i)>=0
r(i)=n(i);
else r(i)=0;
end
end
subplot (2,3,3)
plot2d3 (n,r)
xlabel("Time")
ylabel("Amplitude")

//for continuous time unit impluse signal//

t=input ('enter t=');


for i=1 :length(t)
if t(i)==0
yc(i)=1;
Department of ECE Page 20
Digital Signal Processing Lab

else yc(i)=0;
end
end
subplot (2,3,4)
plot (t,yc)
xlabel("Time")
ylabel("Amplitude")

//for continuous time unit step signal//


for i=1 :length(t)
if t(i)>=0
uc(i)=1;
else uc(i)=0;
end
end
subplot (2,3,5)
plot (t,uc)
xlabel("Time")
ylabel("Amplitude")

//for continuous time unit ramp signal//


for i=1 :length(t)
if t(i)>=0
rc(i)=t(i);
else rc(i)=0;
end
end
subplot (2,3,6)
plot (t,rc)
xlabel("Time")
ylabel("Amplitude")

Department of ECE Page 21


Digital Signal Processing Lab

OUTPUT:

Figure 1.6: Continuous and discrete time Impulse, Step and Ramp Signal

RESULT:-Impulse, Step and Ramp signals in Continuous & Discrete domain have been
plotted as shown in Fig 1.6. These signals have been plotted using their mathematical
expressions.

DISCUSSION:
1. What are the practical applications of unit step function.
2. Differentiate between unit step and unit impulse function.
3. Draw y(t)= u(t+2)- u (t-2)
4. Draw y(t)= 2u(n+1) – u(n-1)
5. What are Exponential and Ramp signals?
6. What are stable and unstable signals?

\\

Department of ECE Page 22


Digital Signal Processing Lab

EXPERIMENT NO: 2

AIM: To Perform basic operations on signals like adding and subtracting, shifting and scaling

SOFTWARE USED: Scilab 6.1.0

THEORY:
The first and foremost operation which we will consider will be addition. The addition of
signals is very similar to traditional mathematics. That is, if x1(t) and x2(t) are the two
continuous time signals, then the addition of these two signals is expressed as x1(t) + x2(t).
The resultant signal can be represented as y(t) from which we can write
y(t) = x1(t) + x2(t)
Similarly, for discrete time signals, x1[n] and x2[n], we can write
y[n] = x1[n] + x2[n]
Similar to the case of addition, subtraction deals with the subtraction of two or more signals
in order to obtain a new signal.
Mathematically it can be represented as
y(t) = x1(t)- x2(t) for continuous time signals, x1(t) and x2(t)
y[n] = x1[n] - x2[n] for discrete time signals, x1[n] and x2[n]
Time Shifting: The time-shifting operation results in the change of just the positioning of
the signal without affecting its amplitude or span.
Time-Delayed Signals: This signal is shifted to right side of the origin
y[n] = x[n-k].
This kind of signal is referred to as time-delayed because the signal arrives late compared to
the original signal.
Time-Advanced Signals: This signal is shifted to left side of the origin signal.
y[n] = x[n+k].
This kind of signal is referred to as time-delayed because the signal arrives earlier than
original signal.

Time Reversal: It results in the reflection of the signal along its vertical axis of reference. As
a result, the operation is known as the time reversal or time reflection of the signal.

Department of ECE Page 23


Digital Signal Processing Lab

PROGRAM:

clc ;
clear all;
close ;
t = -1:0.1:5;
x1 = 1;
x2 = 2;
x3 = 3- t ;
xa = x1 .*( t >0 & t <1) + x2 .*( t >=1 & t <=2) + x1 .*( t >2& t <3) ;
xb = t .*( t >0 &t <1) + x1 *( t >=1 &t <=2) + x3 .*( t >2 &t <3) ;
xadd = xa + xb ;
xmul = xa - xb ;
subplot (2 ,3 ,1) ;
plot2d3 (t , xa ) // P l o t s i n p u t s i g n a l xa
xlabel ( 't') ;
ylabel ( 'Ampli tude') ;
title ( 'input signal xa') ;
subplot (2 ,3 ,2) ;
plot2d3 (t , xb ) // P l o t s i n p u t s i g n a l xb
xlabel ( 't' ) ;
ylabel ('Ampli tude') ;
title ('input signal xb') ;
subplot (2 ,3 ,3) ;
plot2d3 (t , xadd ) // P l o t s a d d i t i o n of s i g n a l xa andxb
xlabel ('t') ;
ylabel ('Ampli tude') ;
title ('Addition of two signals, xadd') ;
subplot (2 ,3 ,4) ;
plot2d3 (t , xmul ) // P l o t s Subtraction of s i g n a l xaand xb
xlabel ( 't') ;
ylabel ('Ampli tude') ;
title ('Subtraction of two signals, xmul') ;

Department of ECE Page 24


Digital Signal Processing Lab

OUTPUT

Fig 2.1 Addition and Subtraction of signals

PROGRAM
// Program to demostrate the shifting of the discrete time signal
clc ;
clear ;
close ;
x = input ('Rnter the input sequence:=')
m = length ( x ) ;
lx = input ('Enter the starting point of original signal:=' )
hx = lx +m -1;
n = lx :1: hx ;
subplot (3 ,1 ,1)
a = gca () ;
a . x_location ="origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x );
xlabel ('n===>')
ylabel ('Amplitdue−−−>')
title ('original sequence')
d = input ('Enter the delay:=')
n = lx + d :1: hx + d ;
subplot (3 ,1 ,2)
a = gca () ;
a . x_location = "origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x)
xlabel ('n===>')
ylabel ('Amplitude−−−>' )
title ('Delayed Sequence')
a = input ('Enter the advance :=')
n = lx - a :1: hx - a ;
Department of ECE Page 25
Digital Signal Processing Lab

subplot (3 ,1 ,3)
a = gca () ;
a . x_location = "origin";
a . y_location = "origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x)
xlabel ( 'n===>')
ylabel ( 'Amplitude−−−>')
title ( 'Advanced Sequence')

OUTPUT

Enter the input sequence:=[1 2 3 4 5]

Enter the starting point of original signal:=0

Enter the delay:=2

Enter the advance :=3

Fig 2.2 Shifting of the discrete time signal

Department of ECE Page 26


Digital Signal Processing Lab

PROGRAM
// Program to demonstrate amplitude and time scaling of a signal
clc ;
clear ;
x = input ('Enter input sequence:=') ;
m = length ( x ) ;
lx = input ('Enter starting point of original sequence:=')
hx = lx +m -1;
n = lx :1: hx ;
subplot (2 ,2 ,1);
a = gca () ;
a . x_location ="origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , x );
xlabel ('n====>');
ylabel ('Amplitude−−−−>');
title ('original sequence');
// Ampli tude S c a l i n g
a = input('Amplitude Scaling factor:=');
y=a*x;
subplot (2 ,2 ,2)
a = gca () ;
a . x_location = "origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn' ,n , y);
xlabel ('n====>');
ylabel ('Amplitdue−−−−>');
title ('Amplitude scaled sequence');
//Time S c a l i n g −Com p r e s sio n
C = input('Enter compression factor −time scaling factor')
n = lx / C :1/ C : hx / C ;
subplot(2 ,2 ,3);
a = gca () ;
a . x_location ="origin";
a . y_location ="origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ('gnn',n , x);
xlabel ('n===>');
ylabel ('Amplitude−−−>');
title ('Compressed sequence');
//Time S c a l i n g −E x pa n sio n
d = input('Time scaling factor');
n = lx * d: d : hx * d ;
subplot(2 ,2 ,4)
a = gca () ;
a . x_location ="origin";
Department of ECE Page 27
Digital Signal Processing Lab

a . y_location = "origin";
a . data_bounds = [ -10 ,0;10 ,10];
plot2d3 ( 'gnn' ,n , x);
xlabel ('n===>');
ylabel ('Amplitude−−−>');
title ('Extended sequence');

OUTPUT:

Enter input sequence:=[1 2 3 4 5]

Enter starting point of original sequence:=2

Amplitude Scaling factor:=2

Enter compression factor −time scaling factor2

Time scaling factor2

Figure2.3: Time scaling of Discrete Time signals

Department of ECE Page 28


Digital Signal Processing Lab

RESULT:-
The output of addition, subtraction and shifting and time scaling operations for the given
discrete time signals is shown in Fig 2.1, 2.2, 2.3.

DISCUSSION:
1. What is the importance of scaling and shifting in digital signal processing?
2. Explain Interpolation and Decimation.
3. How Digital Signal Processing is better than Analog Signal Processing?

Department of ECE Page 29


Digital Signal Processing Lab

This Page is intentionally left blank

Department of ECE Page 30


Digital Signal Processing Lab

EXPERIMENT NO:3

AIM: Perform Continuous and discrete time Convolution (using basic definition).

SOFTWARE USED: Scilab 6.1.0

THEORY:

Convolution:
Convolution is defined as an operation which helps to find the output of the LTI (linear and
time-invariant) system when the impulse response of the system and the input signal are
known.
(Impulse response is defined as behavior of system under unit impulse signal which is defined
for t=0 only)

(a)

(b)
Figure 3.1 LTI system with output represented as convolution between input and
impulse response
a) Continuous time system (b) discrete time system

If a continuous-time system is both linear and time-invariant, then the output Y(t) is related to
the input X(t) and impulse response (h(t)) of the system by the equation given below:
:
(4.1)

Equation 4.1 is also known as convolution integral between X(t) and h(t)

Similarly, if a discrete-time system is both linear and time-invariant, then the output Y(n) is
related to the input X(n) and impulse response (h(n)) of the system by the equation mentioned
below:
(4.2)

Equation 4.2 is also known as convolution sum of X(n) and h(n)

Department of ECE Page 31


Digital Signal Processing Lab

PROGRAM:
//C o n v ol u ti o n Sum of i n p u t s e q u e n c e x [ n]= (2ˆ n ) . u[−n ] and h [ n ] = u [ n ]
PROGRAM

clear ;
close ;
clc ;
Max_Limit = 10;
h = ones (1 , Max_Limit ) ;
N2 =0: length ( h ) -1;
for n = 1: Max_Limit
x1 ( n) = (2^( -( n -1) ) ) *1;
end
x = x1 ( $ : -1:1) ;
N1 = -length ( x ) +1:0;
y = convol (x , h ) ;
N = -length ( x ) +1: length ( h ) -1;
subplot(2,2,1);
plot2d3 ('gnn' ,N2 ,h )
xtitle ('Im p ul s e R e s po n s e ’ , ’ n ’ , ’ h [ n ]') ;
subplot(2,2,2);
plot2d3 ('gnn',N1 ,x )
xtitle ('I n p u t R e s po n s e Fig 2 . 1 1 ( a ) ’ , ’ n ’ , ’ x [ n ]') ;
subplot(2,2,3);
plot2d3 ('gnn',N , y)
xtitle ('Output R e s po n s e Fig 2 . 1 1 ( b ) ’ , ’ n ’ , ’ y [ n ]') ;
OUTPUT

Department of ECE Page 32


Digital Signal Processing Lab

Fig 3.2 Discrete time convolution a) Impulse Response b) Input response c) Convolved
output

PROGRAM

//C o n v ol u ti o n I n t e g r a l of i n p u t x ( t ) = (eˆ−a t ) . u ( t )// and h ( t ) =u ( t )


clear ;
close ;
clc ;
Max_Limit = 10;
h = ones (1 , Max_Limit ) ;
N2 =0: length ( h ) -1;
a = 0.5; // c o n s t a n t a>0
for t = 1: Max_Limit
x ( t ) = exp ( - a *( t -1) ) ;
end
N1 =0: length ( x ) -1;
y = convol (x , h ) -1;
N = 0: length ( x ) + length ( h ) -2;
subplot(2,2,1)
plot2d ( N2 , h )
xtitle ('Im p ul s e R e s po n s e ’ , ’ t ’ , ’ h ( t )') ;

subplot(2,2,2)
plot2d ( N1 , x )
xtitle ('I n p u t R e s po n s e ’ , ’ t ’ , ’ x ( t )') ;

subplot(2,2,3)
plot2d ( N (1: Max_Limit ) ,y (1: Max_Limit ) )
xtitle ('Output R e s po n s e ’ , ’ t ’ , ’ y ( t )') ;

Department of ECE Page 33


Digital Signal Processing Lab

OUTPUT

Figure 3.3: Continuous time convolution a) impulse response b) input response c)


the convolved output

RESULT:-
The output of discrete LTI System with for x [ n]= (2ˆ n ) . u[−n ] and h [ n ] = u [ n ]
is as shown in figure 3.2(c)
The output of continuous LTI System with x ( t ) = (eˆ−a t ) . u ( t ) and h ( t ) =u ( t )
shown in figure 3.3 (c)

DISCUSSION:
1) Differentiate between linear and circular convolution.
2) Determine the unit step response of the linear time invariant system with impulse
response
3) Determine the range of values of the parameter a for which linear time
invariant system with impulse response is stable.
4) Describe impulse response of a function and its importance

Department of ECE Page 34


Digital Signal Processing Lab

EXPERIMENT-4

AIM: Write a program to check Linearity and Time variance property of a system using
convolution, shifting

SOFTWARE USED: MATLAB 7.1.

THEORY:

1. LINEARITY PROPERTY:. Changing the input in a linear way will change the
output in the same linear way. So if the input x(t) produces the output y(t) then input
ax(t) will produce the output ay(t) where a is any constants.
So,
If y(t)=x(t)*h(t)
then ax(t)*h(t)= ay(t)

2. TIME VARIANCE PROPERTY:


If y(t)=x(t)*h(t)
then x(t−t0)*h(t)=y(t−t0)

PROGRAM:
//To c h e c k w h e t h e r t h e g i v e n d i s c r e t e s y s t em i s aL i n e a r System ( o r )
Non−L i n e a r System
// Given d i s c r e t e s y s t em y ( t )= t ∗x ( t )
clear ;
clc ;
x1 = [1 ,1 ,1 ,1];
x2 = [2 ,2 ,2 ,2];
a = 1;
b = 1;
for t = 1: length ( x1 )
x3 ( t ) = a * x1 ( t ) + b* x2 ( t ) ;
end
for t = 1: length ( x1 )

y1 ( t) = t * x1 ( t ) ;
y2 ( t) = t * x2 ( t ) ;
y3 ( t) = t * x3 ( t ) ;
end
for t = 1: length ( y1 )
z ( t ) = a* y1 ( t ) + b * y2 ( t ) ;
end
count = 0;
for n =1: length ( y1 )
Department of ECE Page 35
Digital Signal Processing Lab

if( y3 ( t ) == z ( t ) )
count = count +1;
end
end
if( count == length ( y3 ) )
disp ('S i n c e I t s a t i s i f i e s t h e s u p e r p o s i t i o np r i n c i p l e')
disp ('The g i v e n s y s t em i s a L i n e a r s y s t em')
y3
z
else
disp ('S i n c e I t d o e s no t s a t i s i f y t h es u p e r p o s i t i o n p r i n c i p l e')
disp ('The g i v e n s y s t em i s a Non−L i n e a r s y s t em')
end

OUTPUT
"Since it satisfy the superposition principle"

"The given system is Linear system"

PROGRAM
//To c h e c k w h e t h e r t h e g i v e n d i s c r e t e s y s t em i s aL i n e a r System ( o r )
Non−L i n e a r System
// Given d i s c r e t e s y s t em y [ n ] )= 2∗ x [ n]+3
clear ;
clc ;
x1 = [1 ,1 ,1 ,1];
x2 = [2 ,2 ,2 ,2];
a = 1;
b = 1;
for n = 1: length ( x1 )
x3 ( n ) = a * x1 ( n ) + b* x2 ( n ) ;
end
for n = 1: length ( x1 )
y1 ( n ) = 2* x1 ( n ) +3;
y2 ( n ) = 2* x2 ( n ) +3;
y3 ( n ) = 2* x3 ( n ) +3;
end
for n = 1: length ( y1 )
z ( n ) = a* y1 ( n ) + b * y2 ( n ) ;
end
count = 0;
for n =1: length ( y1 )
if( y3 ( n ) == z ( n ) )
count = count +1;
end
end
if( count == length ( y3 ) )

Department of ECE Page 36


Digital Signal Processing Lab

disp ('S i n c e I t s a t i s i f i e s t h e s u p e r p o s i t i o np r i n c i p l e')


disp ('The g i v e n s y s t em i s a L i n e a r s y s t em')
y3
z
else
disp ('S i n c e I t d o e s no t s a t i s i f y t h es u p e r p o s i t i o n p r i n c i p l e')
disp ('The g i v e n s y s t em i s a Non−L i n e a r s y s t em')
end

OUTPUT
"Since it does not satisfy the superposition principle"

"The given system is Non-Linear system"

PROGRAM
//To c h e c k w h e t h e r t h e g i v e n s y s t em i s a Timev a r i a n t ( o r ) Time In−v a r i a
nt
// The g i v e n d i s c r e t e s i g n a l i s y ( t ) = x (2 t )
clear ;
clc ;
to = 2; //Assume t h e amount of tim e s h i f t =2
T = 10; // Leng th of g i v e n s i g n a l
x = [1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10];
y = zeros (1 , length ( x ) ) ;
for t = 1: length (x ) /2
y ( t ) = x (2* t ) ;
end
// F i r s t s h i f t t h e i n p u t s i g n a l o nl y
Input_shift = x (T - to ) ;
Output_shift = y (T - to ) ;
if( Input_shift == Output_shift )
disp ('The g i v e n d i s c r e t e s y s t em i s a Time In−v a r i a n t s y s t em') ;
else
disp ('The g i v e n d i s c r e t e s y s t em i s a Time V a ri a n ts y s t em ') ;
end

OUTPUT
"The given discrete system is a time variant system "

PROGRAM
//To c h e c k w h e t h e r t h e g i v e n s y s t em i s a Timev a r i a n t ( o r ) Time In−v a r i a
nt
// The g i v e n d i s c r e t e s i g n a l i s y [ n ] = x [ n ]
clear ;
clc ;
no = 2; //Assume t h e amount of tim e s h i f t =2

Department of ECE Page 37


Digital Signal Processing Lab

L = 10; // Leng th of g i v e n s i g n a l
for n = 1: L
x ( n ) = n;
y ( n ) = n* x ( n ) ;
end
// F i r s t s h i f t t h e i n p u t s i g n a l o nl y
Input_shift = x (L - no ) ;
Output_shift = y (L - no ) ;
if( Input_shift == Output_shift )
disp ('The g i v e n d i s c r e t e s y s t em i s a Time In−v a r i a n t s y s t em') ;
else
disp ('The g i v e n d i s c r e t e s y s t em i s a Time V a ri a n ts y s t em') ;
end

OUTPUT:
"The given discrete system is time variant system"

RESULT: The response for time shifting and linearity property has been shown in figure 4.1.

DISCUSSION:
1) Differentiate between linear and circular convolution.
2) What is LTI System?
3) State the Linearity and Time Invariant property of a signal.
4) Describe impulse response of a function and its importance.

Department of ECE Page 38


Digital Signal Processing Lab

EXPERIMENT NO: 5

AIM: To generate and verify random sequences with arbitrary distributions, means and
variances for following:
(a) Rayleigh distributions
(b) Normal distributions: N (0,1).
(c) Gaussian distributions: N (m, x)
(d) Random binary wave.

SOFTWARE USED: Scilab 6.1.0

THEORY:
The term random signal is used primarily to denote signals, which have a randomness in its
nature source. As an example we can mention the thermal noise, which is created by the
random movement of electrons in an electric conductor.
Random signals are those signals whose behavior cannot be predicted using any past
reference.
Random signals are those that do not repeat with any definite sequence, but rather must be
described in terms of some probability. The characteristics of random signal are primarily
determined by its probability distribution function (PDF). There are many types of PDF
available to characterize the behavior of random signals as:
1. Gaussian distribution
2. Rayleigh distribution
3. Gamma distribution
4. Uniform Distribution
And many more……..

In this experiment we are mainly concerned about three types of distribution i.e.
1. Gaussian distribution
2. Rayleigh distribution
3. Normal distribution

Gaussian Distribution:
Gaussian distribution (also known as normal distribution) is a bell-shaped curve, and it is
assumed that during any measurement values will follow a normal distribution with an
equal number of measurements above and below the mean value.
The PDF of Gaussian distribution of random signal x is

: variance of the PDF, is the standard deviation, : mean of the PDF. The

Department of ECE Page 39


Digital Signal Processing Lab

PDF of Gaussian distribution is as shown in fig below

Figure 5.1: PDF of Gaussian distributed signal

Communication noise is generally modeled with Gaussian distribution. Noise is assumed to


be AWGN (Additive White Gaussian Noise)

2. Normal Distribution:
Gaussian distribution with mean =0 and variance=1, is known to be standard normal
distribution. The PDF of normal distribution is:

3. Rayleigh Distribution:
In probability theory and statistics, the Rayleigh distribution is a continuous probability
distribution for nonnegative-valued random variables. Wireless channel communication and
its related fading problem is generally characterized by Rayleigh distribution.
; x>0

Figure 5.2: Rayleigh distribution

Random Binary Wave:


A binary wave is made of a sequence of random symbols 1’s and 0’s.

Department of ECE Page 40


Digital Signal Processing Lab

Figure 5.3: Random Binary Wave


PROGRAM:
clc;
clear;
close;
X=-10:0.01:10;
m=input("Enter mean of the signal : ");
var=input("Enter variance of the signal : ");
y=exp(-(X-m)^2/(2*var^2))/(2*%pi*var^2)^0.5
subplot(3,1,1);
plot(X,y);
xlabel("X");
ylabel("PDF");
title("Gaussian Distribution Curve");

MEAN = 0;
VAR=1;
u=exp(-(X-MEAN)^2/(2*VAR^2))/(2*%pi*VAR^2)^0.5
subplot(3,1,2);
plot(X,u);
xlabel("X");
ylabel("PDF");
title("Normal Distribution curve");

P=0:0.01:20;
var2=input("Enter the variance of the signal : ");
px=P.*exp(-(P^2/(2*var2^2)))/var2^2;
subplot(3,1,3);
plot(P,px);
xlabel("X");
ylabel("PDF");
title("Rayleigh Distribution curve");

OUTPUT

Enter mean of the signal : 2

Department of ECE Page 41


Digital Signal Processing Lab

Enter variance of the signal : 4

Enter the variance of the signal : 4

Fig 5.4 a) Gaussian Distribution b) Normal Distribution c) Rayleigh distribution

PROGRAM
//SWITCH CASE:
clc
clear

i=1
while(i==1)
disp('enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave');
c=input('Enter your choice')
switch(c)
case 1
x=-5:0.01:5;
mean=2;
var=2
px=(exp(-((x-mean)^2)/(2*var*var)))/((2*%pi*var*var)^0.5);
figure
subplot(1,4,1)

Department of ECE Page 42


Digital Signal Processing Lab

plot(x,px)

case 2
x=-5:0.01:5;
mean=0;
var=1
px=(exp(-((x-mean)^2)/(2*var*var)))/((2*%pi*var*var)^0.5);
figure
subplot(1,4,2)
plot(x,px)

case 3
x=0:0.01:5;
r=2;
pr=(x/(r^2)).*exp(-x.*x/(2*r*r)) ;
figure
subplot(1,4,3)
plot(x,pr)

case 4
figure
y=prbs_a(20,7);
subplot(1,4,4)
plot2d2(y)
end

i=input('do you want to continue press 1 and 0 for exit ')

end

OUTPUT:

enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random bina ry wave
Enter your choice1
do you want to continue press 1 and 0 for exit 1

1
Fig 5.5 (a) Gaussian Distribution

Department of ECE Page 43


x
Digital Signal Processing Lab

enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave
Enter your choice2

do you want to continue press 1 and 0 for exit 1

Fig 5.5 (b) Normal Distribution

enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave
Enter your choice3
do you want to continue press 1 and 0 for exit 1

Fig 5.5 (c) Rayleigh Distribution

enter 1 for gaussian, 2 for normal: 3 for rayleigh:, 4 for random binary wave
Enter your choice4
do you want to continue press 1 and 0 for exit 0

Department of ECE Page 44


Digital Signal Processing Lab

Fig 5.5 (d) Binary wave

RESULT:-
The different probability distributions have been computed for specified parameters and the
pdfs of Gaussian, normal and random binary waves is shown in figure 5.4 & 5.5 respectively.

DISCUSSION:-
1. Define AWGN and how its useful in communication system?
2. What does the variance of Gaussian distribution specify?
3. What does the mean of probability distribution function specify?
4. Which random data is modeled by Gaussian and Rayleigh probability distribution?

Department of ECE Page 45


Digital Signal Processing Lab

This page is intentionally left blank

Department of ECE Page 46


Digital Signal Processing Lab

EXPERIMENT NO: 6

AIM: To find DFT / IDFT of given DT signal.

SOFTWARE USED: Scilab 6.1.0.

THEORY:
The discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of
a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier
transform (DTFT), which is a complex-valued function of frequency. The interval at which
the DTFT is sampled is the reciprocal of the duration of the input sequence.
The DFT is the most important discrete transform, used to perform Fourier analysis in many
practical applications. In digital signal processing, the function is any quantity or signal that
varies over time, such as the pressure of a sound wave, a radio signal, or
daily temperature readings, sampled over a finite time interval.

The DFT (X(k)) of a discrete sequence x(n) of Length N will be:


;

Similarly IDFT of X(k) will be

PROGRAM:
clf;

clear;

x=input("Enter the signal : ");

N=length(x);

y=0:N-1;

r=0:N-1;

W=exp(-%i*2*%pi*y'*r/N);

X=x*W;

Department of ECE Page 47


Digital Signal Processing Lab

mag=abs(X);

phase=atan(imag(X),real(X));

subplot(2,2,1);

plot2d3(r,x);

xlabel('n');

ylabel('x(n)');

title('Input Signal');

subplot(2,2,2);

plot2d3(r,mag);

xlabel('k');

ylabel('X(k)');

title('Magnitude of X(k)');

subplot(2,2,3);

plot2d3(r,phase);

xlabel('k');

ylabel('X(k)');

title('Phase of X(k)');

W1=exp(%i*2*%pi*y'*r/N);

X1=X*W1;

mag1=abs(X1);

subplot(2,2,4);

plot2d3(r,mag1);

xlabel('k');

ylabel('X(k)');

title('IDFT signal');

Department of ECE Page 48


Digital Signal Processing Lab

Figure 6.1: DFT and IDFT phase and magnitude response

OUTPUT
Enter the discrete time sequence: [1 2 3 4]

RESULT: The DFT and IDFT phase and magnitude response is shown in Fig 6.1

DISCUSSION:
1. What is the difference between DTFT and DFT?
2. What is the need to study DFT Signal?
3. How the DTFT signal is converted into DFT?
4. List the important properties of DFT

Department of ECE Page 49


Digital Signal Processing Lab

This Page is intentionally left blnk

Department of ECE Page 50


Digital Signal Processing Lab

EXPERIMENT NO: 7

AIM: N-point FFT algorithm.

SOFTWARE USED: Scilab 6.1.0

THEORY:
A fast Fourier transform (FFT) is an efficient algorithm to compute the discrete Fourier
transform (DFT) and its inverse. FFTs are of great importance to a wide variety of
applications, from digital signal processing and solving partial differential equations to
algorithms for quick multiplication of large integers. Evaluating the sums of DFT directly
would take O(N 2) arithmetical operations. An FFT is an algorithm to compute the same
result in only O(N log N) operations. In general, such algorithms depend upon the
factorization of N, but there are FFTs with O(N log N) complexity for all N, even for
prime N. Since the inverse DFT is the same as the DFT, but with the opposite sign in the
exponent and a 1/N factor, any FFT algorithm can easily be adapted for it as well

FFT: -Fast Fourier transform.


There are two methods.
1. Decimation in time (DIT ) FFT.
2. Decimation in Frequency (DIF) FFT.
Dividing the DFT into smaller DFTs is the basis of the FFT. A radix-2 FFT divides the DFT
into
two smaller DFTs, each of which is divided into smaller DFTs and so on, resulting in a
combination of two-point DFTs. The Decimation -In-Time (DIT) FFT divides the input (time)
sequence into two groups, one of even samples and the other of odd samples. N/2 point DFT
are
performed on the these sub-sequences and their outputs are combined to form the N point
DFT.
The Fast Fourier Transform (FFT) is just a computationally fast way to calculate the DFT

For FFT.
The no of multiplication = N/2 log 2N.
The no of additions = N log2 N.

Department of ECE Page 51


Digital Signal Processing Lab

PROGRAM:
clc ;
clear ;
// Le t x ( n ) ={ 1 , 2 , 1 , 2 , 0 , 2 , 1 , 2 }
// Le t u s b e gi n wi t h t h e programming . Foru n d e r s t a n di n g , l e t u s w r i t e t h e g
i v e n da ta a s
// x ( 0 ) =1; x ( 1 ) =2,x ( 2 ) =1,x ( 3 ) =2,x ( 4 ) =0,x ( 5 ) =2,x ( 6 ) =1,x( 7 )=2
x0 =1; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x4 =0; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x2 =1; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x6 =1; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x1 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x5 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x3 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
x7 =2; //DIT−FFT, so a r r a n g i n g t h e i n p u t i n bi t −r e v e r s e d o r d e r
// S t a g e I com p u ta tio n
x0a = x4 + x0 ; // Computing S tage−I o u t p u t a t l i n e 1
disp ( x0a ,"S tage−I o u t p u t a t l i n e 1=")
x4b =( x4 - x0 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x4b ,"S tage−I o u t p u t a t l i n e 2=")
x2c = x6 + x2 ; // Computing S tage−I o u t p u t a t l i n e 3
disp ( x2c ,"S tage−I o u t p u t a t l i n e 3=")
x6d =( x6 - x2 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x6d ,"S tage−I o u t p u t a t l i n e 4=")
x1e = x5 + x1 ; // Computing S tage−I o u t p u t a t l i n e 5
disp ( x1e ,"S tage−I o u t p u t a t l i n e 5=")
x5f =( x5 - x1 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x5f ,"S tage−I o u t p u t a t l i n e 6=")
x3g = x7 + x3 ; // Computing S tage−I o u t p u t a t l i n e 7
disp ( x3g ,"S tage−I o u t p u t a t l i n e 7")
x7h =( x7 - x3 ) *( -1) ; // Computing S tage−I o u t p u t a t l i n e
disp ( x7h ,"S tage−I o u t p u t a t l i n e 8=")
// S tage−I o u t p u t a t l i n e 4 and l i n e 8 i s to bem u l t i p l i e d by t w i d d l e f a c t o r
ha vi ng v a l u e (− j )
x6d1 =( x6d ) *( - sqrt ( -1) ) ;
x7h1 =( x7h ) *( - sqrt ( -1) ) ;
disp ( x6d1 ,"S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r v a l u e of(− j ) a t l i n e 4 =")
disp ( x7h1 ,"S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r v a l u e of(− j ) a t l i n e 8 =")
// S tage−I I Compu ta tion s
x0a_stageII_output = x2c + x0a ; // Computing S tage−I Io u t p u t a t l i n e 1
disp ( x0a_stageII_output ,"S tage−I I o u t p u t a t l i n e 1=")
x4b_stageII_output = x6d1 + x4b ; // Computing S tage−I Io u t p u t a t l i n e 2
disp ( x4b_stageII_output ,"S tage−I I o u t p u t a t l i n e 2=")
x2c_stageII_output =( x2c - x0a ) *( -1) ; // Computing S tage−I I o u t p u t a t l i n e 3
Department of ECE Page 52
Digital Signal Processing Lab

disp ( x2c_stageII_output ,"S tage−I I o u t p u t a t l i n e 3=")


x6d_stageII_output =( x6d1 - x4b ) *( -1) ; // Computing S tage−I I o u t p u t a t l i n e 4
disp ( x6d_stageII_output , "S tage−I I o u t p u t a t l i n e 4=")
x1e_stageII_output = x3g + x1e ; // Computing S tage−I Io u t p u t a t l i n e 5
disp ( x1e_stageII_output ,"S tage−I I o u t p u t a t l i n e 5=")
x5f_stageII_output = x7h1 + x5f ; // Computing S tage−I Io u t p u t a t l i n e 6
disp ( x5f_stageII_output ,"S tage−I I o u t p u t a t l i n e 6=")
x3g_stageII_output =( x3g - x1e ) *( -1) ; // Computing S tage−I I o u t p u t a t l i n e 7
disp ( x3g_stageII_output ,"S tage−I I o u t p u t a t l i n e 7=")
x7h_stageII_output =( x7h1 - x5f ) *( -1) ; // Computing S tage−I I o u t p u t a t l i n e 8
disp ( x7h_stageII_output ,"S tage−I I o u t p u t a t l i n e 8=")
// S tage−I I o u t p u t a t l i n e 6 , l i n e 7 and l i n e 8 a r e tobe m u l t i p l i e d by t w i d d
l e f a c t o r ha vi ng v a l u e(0.707 − j 0 . 7 0 7 ) ,(− j ) and (−0.707− j 0 . 7 0 7 )r e s p e c t
ively
x5f_stgII_op_multi_by_tw =( x5f_stageII_output )*(0.707 -( sqrt ( -1) ) *(0.707) ) ;
disp ( x5f_stgII_op_multi_by_tw ,"S tage−I I o u t p u t a tl i n e 6 a f t e r m u l t i p l i c a t i
o n by t w i d d l e f a c t o r=")
x3g_stgII_op_multi_by_tw =( x3g_stageII_output ) *( -(sqrt ( -1) ) ) ;
disp ( x3g_stgII_op_multi_by_tw , "S tage−I I o u t p u t a tl i n e 7 a f t e r m u l t i p l i c a t i
o n by t w i d d l e f a c t o r=")
x7h_stgII_op_multi_by_tw =( x7h_stageII_output )*( -0.707 -( sqrt ( -1) ) *(0.707) ) ;
disp ( x7h_stgII_op_multi_by_tw ,"S tage−I I o u t p u t a tl i n e 8 a f t e r m u l t i p l i c a t i
o n by t w i d d l e f a c t o r=")
// S tage−I I I Compu ta tion s ( i . e . Compu ta tion s f o r t h ef i n a l s t a g e )
X0 = x1e_stageII_output + x0a_stageII_output ; // ComputingX( 0 ) a t l a s t s t a g e
X1 = x5f_stgII_op_multi_by_tw + x4b_stageII_output ; //Computing X( 1 ) a t l a s t s t a g e
X2 = x3g_stgII_op_multi_by_tw + x2c_stageII_output ; //Computing X( 2 ) a t l a s t s t a g e
X3 = x7h_stgII_op_multi_by_tw + x6d_stageII_output ; //Computing X( 3 ) a t l a s t s t a g e
X4 =( x1e_stageII_output - x0a_stageII_output ) *( -1) ; //Computing X( 4 ) a t l a s t s t a g e
X5 =( x5f_stgII_op_multi_by_tw - x4b_stageII_output )*( -1) ; // Computing X( 5 ) a t l a s t
stage
X6 =( x3g_stgII_op_multi_by_tw - x2c_stageII_output )*( -1) ; // Computing X( 6 ) a t l a s t
stage
X7 =( x7h_stgII_op_multi_by_tw - x6d_stageII_output )*( -1) ; // Computing X( 7 ) a t l a s t
stage
disp ( X0 ,"X( 0 )=")
disp ( X1 ,"X( 1 )=")
disp ( X2 ,"X( 2 )=")
disp ( X3 ,"X( 3 )=")
disp ( X4 ,"X( 4 )=")
disp ( X5 ,"X( 5 )=")
disp ( X6 ,"X( 6 )=")
disp ( X7 ,"X( 7 )=")
disp ([X0 , X1 , X2 , X3 , X4 , X5 , X6 ,X7] ,"So , t h e DFT of x ( n )u s i n g Decima
tion−in−Time Fa s t F o u r i e r T ran sfo rm (DIT−FFT) i s X( k )=");

Department of ECE Page 53


Digital Signal Processing Lab

OUTPUT:-

S tage−I o u t p u t a t l i n e 1=

1.

S tage−I o u t p u t a t l i n e 2=

1.

S tage−I o u t p u t a t l i n e 3=

2.

S tage−I o u t p u t a t l i n e 4=

0.

S tage−I o u t p u t a t l i n e 5=

4.

S tage−I o u t p u t a t l i n e 6=

0.

S tage−I o u t p u t a t l i n e 7

4.

S tage−I o u t p u t a t l i n e 8=

0.

S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u
l t i p l i c a t i o n by t w i d d l e f a c t o r v a l u e of(− j )
atline4=
0.

S tage−I o u t p u t ( i . e . i n p u t to s t a g e −I I )a f t e r m u
l t i p l i c a t i o n by t w i d d l e f a c t o r v a l u e of(− j )
atline8=
0.

S tage−I I o u t p u t a t l i n e 1=

Department of ECE Page 54


Digital Signal Processing Lab

3.

S tage−I I o u t p u t a t l i n e 2=

1.

S tage−I I o u t p u t a t l i n e 3=

-1.

S tage−I I o u t p u t a t l i n e 4=

1.

S tage−I I o u t p u t a t l i n e 5=

8.

S tage−I I o u t p u t a t l i n e 6=

0.

S tage−I I o u t p u t a t l i n e 7=

0.

S tage−I I o u t p u t a t l i n e 8=

0.

S tage−I I o u t p u t a tl i n e 6 a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r=
0.

S tage−I I o u t p u t a tl i n e 7 a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r=
0.

S tage−I I o u t p u t a tl i n e 8 a f t e r m u l t i p l i c a t i o n
by t w i d d l e f a c t o r=
0.

X( 0 )=

11.

Department of ECE Page 55


Digital Signal Processing Lab

X( 1 )=

1.

X( 2 )=

-1.

X( 3 )=

1.

X( 4 )=

-5.

X( 5 )=

1.

X( 6 )=

-1.

X( 7 )=

1.

So , t h e DFT of x ( n )u s i n g Decima tion−in−Time Fa s t F o u r i e


r T ran sfo rm (DIT−FFT) i s X( k )=
11. 1. -1. 1. -5. 1. -1. 1.

RESULT:

FFT of the sequence x[n]=[ 1 , 2 , 1 , 2 , 0 , 2 , 1 , 2] is given by X[k]= [1,-1,1,-5,1,-1,1]

DISCUSSION:
1. Differentiate Fourier transform and discrete Fourier transform
2. Differentiate DFT and DTFT.
3. What are the advantages of FFT over DFT?
4. What is meant by twiddle factor and give its properties?
5. Compare FFT and DFT with respect to number of calculation required?
6. How the original signal is reconstructed from the FFT of a signal?

Department of ECE Page 56


Digital Signal Processing Lab

EXPERIMENT NO: 8

AIM: To implement circular convolution

SOFTWARE USED: Scilab 6.1.0

THEORY:

Circular convolution resembles the linear convolution, except that the sample values of one
of the input signals is folded and right shifted before the convolution sum is found.
Also circular convolution could also be found by taking the DFT of the two
input signals and finding the product of the two frequency domain signals. The
Inverse DFT of the product would give the output of the signal in the time domain
which is the circular convolution output. The two input signals could have been of
varying sample lengths.
Circular convolution resembles the linear convolution, except that the sample values of one
of the input signals is folded and right shifted before the convolution sum is found.
It is expressed as matrix multiplication. Here an N*N matrix is set up whose columns are
equal to sequence and its cyclically shifted versions. This is called circulant matrix. An N*N
circulant matrix C for x(n) has general form

x(0) x(N-1) ……. x(2) x(1)


C= x(1) x(0) …….. x(3) x(2)
….. …… ……. ….. ……..
x(N-2) x(N-3) ……. x(0) x(N-1)
x(N-1) x(N-2) …….. x(1) x(0)

This matrix is multiplied with transpose of 2nd input matrix to find circularly convolved
output

PROGRAM:

//AIM: Devlop a program f o r c i r c u l a r C onv olu ti on o ftwo s e q u e n c e s u s i n g s c


ilab
clc ;
clf ();
clear ;
x = input ("ENTER THE FIRST SEQUENCE [ us e s qu a r eb r a ck e t − a r r a y form ]=");
// x ( n ) =[1 2 3 5 64 ]

Department of ECE Page 57


Digital Signal Processing Lab

h = input ("ENTER THE SECOND SEQUENCE ="); //h ( n )=[1 2 3 1 ]


N1= length (x);
N2= length (h);
N= max (N1 ,N2);
N3=N1 -N2;
if(N3>=0) then
h=[h, zeros(1, N3)];
else
x=[x, zeros(1,-N3)];
end
for n =1: N
y(n)=0;
for i =1: N
j=n-i+1;
if(j <=0)
j=N+j;
end
y(n)=y(n)+x(i)*h(j)
end
end
disp (y, 'C i r c u l a r c o n v o l u t i o n i s =')
subplot (3,1,1);
plot2d3 ('gnn',x);
a = gca ();
a. x_location ="origin";
a. y_location ="origin";
title ('S i g n a l − 1',"f o n t s i z e",3 );
xlabel ('Number o f Sample−−−−−−>');
ylabel ('Amplitude −−−−−>');
subplot (3,1,2)
plot2d3 ('gnn',h);
a = gca ();
a. x_location = "origin";
a. y_location ="origin";
title ('S i g n a l − 2' ,"font size" ,3 );
xlabel ('Number o f Sample−−−−−−>');
ylabel ('Amplitude −−−−−>');
subplot (3,1,3);
plot2d3 ( 'gnn' ,y);
a = gca ();
a. x_location = "origin";
a. y_location = "origin";
title ('CIRCULAR CONVOLUTION' ,"f o n t s i z e",3 );
xlabel ('Number o f Sample−−−−−−>');
ylabel ('Amplitude −−−−−>');

Department of ECE Page 58


Digital Signal Processing Lab

OUTPUT

RESULT:
ENTER THE FIRST SEQUENCE [ us e s qu a r eb r a ck e t − a r r a y form ]=[1 2 3 4 5 6 4]

ENTER THE SECOND SEQUENCE =[1 3 2 1]


30.
19.
15.
18.
25.
32.
36.

"C i r c u l a r c o n v o l u t i o n i s ="

DISCUSSION:

Department of ECE Page 59


Digital Signal Processing Lab

1) Differentiate between linear and circular convolution.


2) What is the importance of linear and circular convolution in signals and systems?
3) How will you perform linear convolution via circular convolution?
4) What is the length of linear and circular convolutions if the two sequences are having
length n1 and n2?

Department of ECE Page 60


Digital Signal Processing Lab

This Page is intentionally left blank

Department of ECE Page 61


Digital Signal Processing Lab

EXPERIMENT NO: 9

AIM: MATLAB Code for implementing z-transform and inverse Z-transform

SOFTWARE USED: Scilab 6.1.0

THEORY:

Z transform is used to convert time domain signal into Z-domain. Z-domain is the complex
frequency plane and is used to find the frequency response of signals. It is the generalized
form of converting discrete time domain into frequency domain. It’s related to DTFT
(Discrete time Fourier Transform) in which DTFT obtained signal is multiplied by a
converging factor to make it stable in the desired range of frequency. The Z-transform of
signal x(n) is defined as:

The inverse Z-transform of signal X(z) is defined as:

In MATLAB ztrans() and iztrans() are used to find the z-transpose and inverse Z-transpose
respectively.

PROGRAM:

clc;
clear;
x = input("Enter the discrete signal : ");
Z=poly(0,"z");
n=0:length(x)-1;
X=x.*Z^-n;

Department of ECE Page 62


Digital Signal Processing Lab

Xz=sum(X);
disp("Z transform of the signal is :");
disp(Xz);
disp("ROC of the signal is entire Z plane except 0");
t=length(x)-1;
num=9+Z+6*Z^2+3*Z^3;
den = Z^t;
y=ldiv(num,den,4);
disp("Inverse Z transform of the signal is : ");
disp(y’);
RESULT:
Enter the discrete signal : [3,6,2,8]

"Z transform of the signal is :"

8 +2z +6z² +3z³


---------------

"ROC of the signal is entire Z plane except 0"

"Inverse Z transform of the signal is : "

3. 6. 1. 9.

DISCUSSION:

1. What is the difference between DTFT and Z-transform?


2. What is the need to study Z-transform?
3. How the DTFT signal is converted into Z-transform?
4. List the important properties of Z-transform and its ROC.

Department of ECE Page 63


Digital Signal Processing Lab

This Page is intentionally left blank

Department of ECE Page 64


Digital Signal Processing Lab

EXPERIMENT 10

AIM: Perform inverse Z transform using residue z MATLAB function

SOFTWARE USED: MATLAB 7.1.

THEORY:

Z transform is used to convert time domain signal into Z-domain. Z-domain is the complex
frequency plane and is used to find the frequency response of signals. It is the generalized
form of converting discrete time domain into frequency domain. It’s related to DTFT
(Discrete time Fourier Transform) in which DTFT obtained signal is multiplied by a
converging factor to make it stable in the desired range of frequency. The Z-transform of
signal x(n) is defined as:

The inverse Z-transform of signal X(z) is defined as:

Inverse Z transform can be easily found using inverse transformation method.

We can evaluate the inverse z transform via Cauchy’s residue theorem which states that

x[n] = = ]

where ) is the “residue” of F(z) = at the pole λk with algebraic

multiplicity mk, defined as

)= z = λk

Cauchy’s residue theorem allows to compute the contour integral by computing derivatives.

PROGRAM:

Department of ECE Page 65


Digital Signal Processing Lab

clc;
clear;
x = input("Enter the discrete signal : ");
Z=poly(0,"z");
n=0:length(x)-1;
X=x.*Z^-n;
Xz=sum(X);
disp("Z transform of the signal is :");
disp(Xz);
disp("ROC of the signal is entire Z plane except 0");
t=length(x)-1;
num=9+Z+6*Z^2+3*Z^3;
den = Z^t;
y=ldiv(num,den,4);
disp("Inverse Z transform of the signal is : ");
disp(y’);
OUTPUT
Enter the discrete signal : [3,6,2,8]

"Z transform of the signal is :"

8 +2z +6z² +3z³


---------------

"ROC of the signal is entire Z plane except 0"

"Inverse Z transform of the signal is : "

3. 6. 1. 9.

RESULT: Inverse z transform of the signal has been calculated


Department of ECE Page 66
Digital Signal Processing Lab

DISCUSSION:

1. What is the difference between DTFT and Z-transform?


2. What is the need to study Z-transform?
3. How the DTFT signal is converted into Z-transform?
4. List the important properties of Z-transform and its ROC.

Department of ECE Page 67


Digital Signal Processing Lab

This Page is intentionally left blank

Department of ECE Page 68


Digital Signal Processing Lab

EXPERIMENT NO: 11

AIM: To find frequency response of analog LP/HP filters.

SOFTWARE USED: Scilab 6.1.0

THEORY: Analog filters are made up of resistors, capacitors, o-amps to produce required
output. These are mainly of two types:

1. Butterworth Filter
Butterworth filters are causal in nature and of various orders, the lowest order
being the best (shortest) in the time domain, and the higher orders being better in the
frequency domain. Butterworth or maximally flat filters have a monotonic amplitude
frequency response which is maximally flat at zero frequency response and the
amplitude frequency response decreases logarithmically with increasing frequency.
A Butterworth filter is characterized by its magnitude frequency response,

where N is the order of the filter and Ωc is defined as the cutoff frequency where the filter
magnitude is 1/√2 times the dc gain (Ω=0).

PROGRAM
fcut = 7; //hz
n = 7; // Filter order
hc1 = analpf(n, 'cheb1', [0.1 0], fcut*2*%pi);
hc2 = analpf(n, 'cheb2', [0 0.1], fcut*2*%pi);
he = analpf(n, 'ellip', [0.1 0.1], fcut*2*%pi);
hb = analpf(n, 'butt', [0 0], fcut*2*%pi);

clf();
[fr, hf] = repfreq(hc1, 0, 15);
plot(fr, abs(hf), 'b')
[fr, hf] = repfreq(hc2, 0, 15);
plot(fr,abs(hf),'g')
[fr, hf] = repfreq(he, 0, 15);
plot(fr,abs(hf),'r')
[fr, hf] = repfreq(hb, 0, 15);

Department of ECE Page 69


Digital Signal Processing Lab

plot(fr, abs(hf), 'c')

legend(["Chebyshev I", "Chebyshev II", "Elliptic", "Butterworth"]);


xgrid()
xlabel("Frequency (Hz)")
ylabel("Gain")
title("Analog filters of order 7")

Figure 11.1: Frequency response

RESULT:
The frequency response of analog low pass Low Pass Chebyshev I", "Chebyshev II",
"Elliptic", "Butterworth” are shown in Fig. 11.2

DISCUSSION:
1. List some advantages of digital filters over analog filters.
2. Write some differences between FIR and IIR filters.
3. What are the different methods to design IIR filters?
4. Why IIR filters are not reliable?
5. What are different applications of IIR filters?
6. What are advantages of IIR filters?
7. Differentiate Butterworth and Chebyshev approximations.
8. What is meant by impulse response?

Department of ECE Page 70


Digital Signal Processing Lab

EXPERIMENT NO: 12

AIM: To design FIR filter (LP/HP) using windowing (rectangular, triangular, kaiser)
technique.

SOFTWARE USED: MATLAB 7.1.

THEORY:
Finite Impulse Response (FIR) Filters designed by using finite samples of Impulse response
are called FIR Filters. For the designing of Finite filters, windows of finite duration are used.
The windows are used to modify the impulse response of FIR filters in order to reduce the
ripples in the passband and stopband.
The different types of window sequence to design the FIR filter are as below:

1. Rectangular window
2. Triangular window
3. Raised Cosine windows
4. Hanning window
5. Hamming window
6. Kaiser window

1. Rectangular window
Rectangular window is defined as finite response of window that shows the
rectangular window

Alternatively,

2. Triangular window Triangular


window have been chosen such that it has tapered sequences from the middle on either
sides.

Alternatively,

Department of ECE Page 71


Digital Signal Processing Lab

3. Kaiser window Design a time


limited window whose Fourier transform is approximate a bandlimited function is a
problem. The approximate should be such that the maximum energy is confined to main
lobe. Kaiser window is a simple approximation to these function in terms of zero order
modified Bessel function of the first kind I0(x)

Where

Alternatively,

Where and

The parameter ‘a’ is an independent variable that can be varied to control the side lobe level
with respect to main-lobe peak. With increase in value of a the magnitude of first side lobe
reduces.
Where is calculated as .

PROGRAM

clc;
close all;
clear all;
rp=input('enter passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter passband freq');
fs=input('enter stopband freq');
f=input('enter sampling freq ');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;

Department of ECE Page 72


Digital Signal Processing Lab

n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
c=input('enter your choice of window function 1. rectangular
2. triangular 3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end

if(c==3)
y=kaiser(n1);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');

Department of ECE Page 73


Digital Signal Processing Lab

%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');

OUTPUT
enter passband ripple0.02
enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
1

Department of ECE Page 74


Digital Signal Processing Lab

LPF
20

-20
Gain in dB-->

-40

-60

-80

-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalized frequency-->

HPF
20

0
Gain in dB-->

-20

-40

-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->

Figure:12.1: Rectangular window filter response

2. Enter passband ripple0.02


enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
2

Department of ECE Page 75


Digital Signal Processing Lab

LPF
0

-10

-20
Gain in dB-->

-30

-40

-50
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalized frequency-->

HPF
0

-5

-10
Gain in dB-->

-15

-20

-25

-30
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->

Figure 12.2: Triangular window filter response

3. Enter passband ripple0.02


enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
3

Department of ECE Page 76


Digital Signal Processing Lab

LPF
20

-20
Gain in dB-->

-40

-60

-80

-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(a) Normalized frequency-->

HPF
20

0
Gain in dB-->

-20

-40

-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->

Figure 12.3: Kaiser window filter response

RESULT:
The response for LP and HP FIR Filter using Rectangular, Triangular and Kaiser window
have been shown in figures 12.1, 12.2 and 12.3 respectively for the sampling frequency
10000 Hz .

DISCUSSION:

1. Differentiate between FIR and IIR filters.


2. What are the different methods to design FIR filters?
3. What are different applications of FIR filters?
4. What is meant by impulse response?

Department of ECE Page 77


Digital Signal Processing Lab

EXPERIMENT 13

AIM: To generate amplitude modulated signal for specific modulation index and plot the
spectrum.

SOFTWARE USED: Scilab 6.1.0

Theory:

Amplitude modulation (AM) is a one of the conventional technique used to transmit message
signals using a carrier wave. The amplitude or strength of the high frequency carrier wave is
modified in accordance with amplitude of the message signal.
First of all lets get into the basics..
• Carrier signal (Sc) = Acsin(2πfct)
• Message signal (Sm) = Amsin(2πfmt) # fm must be smaller than fc

When carrier amplitude is altered with respect to message signal,


• Modulated Signal = (Ac+ Amsin(2 πfmt))*sin(2 πfct)here,
• Ac = Carrier signal amplitude
• Am = Message signal amplitude
• fc= Carrier frequency
• fm =Message frequency
• s(t)= modulated signal

Single Sideband Suppressed Carrier :


The process of suppressing one of the sidebands along with the carrier and transmitting a
single sideband is called as Single Sideband Suppressed Carrier system or simply SSBSC.
The modulated signal s(t) is given by

s(t)=AmAc2cos[2π(fc−fm)t] - For Upper Sideband


s(t)=AmAc2cos[2π(fc−fm)t] - For Lower Sideband

Double Sideband Suppressed Carrier :


If the carrier is suppressed and the saved power is distributed to the two sidebands, then such
a process is called as Double Sideband Suppressed Carrier system or simply DSBSC.
The modulated signal s(t) is given by

s(t)=AmAccos(2πfmt)cos(2πfct)

Department of ECE Page 78


Digital Signal Processing Lab

PROGRAM:

clc ;
clear ;
Fc =500; // c a r r i e r f r e q u e n c y i n kHz
Fm =1; // m e s sag e s i g n a l f r e q u e n c y i n kHz
// a )

USB = Fc + Fm ;
LSB = Fc - Fm ;
disp ( USB ,"USBI ( i n kHZ )=") ;
disp ( LSB ,"LSB ( i n kHz )=") ;
//b )

Bandwidth = USB - LSB ;


disp ( Bandwidth ,"Bandwidth ( i n kHZ )=")
// c )

Fm =1.5; // m e s sag e s i g n a l f r e q u e n c y i n kHz

USB1 = Fc + Fm ;
LSB1 = Fc - Fm ;
disp ( USB1 ,"USB( i n kHz )=") ;
disp ( LSB1 ,"LSB ( i n kHZ )=") ;
Amplitude =[0 0 0 0 0 0 0 0 0 5 10 5 0]; // sam pl e a l u e s
frequency =490:1:502;
plot2d3 ( frequency , Amplitude ) ;
xlabel ("F r e q u e n c y ( i n kHZ )") ;
ylabel ("Ampli tude ( i n V)") ;

OUTPUT:
501.

"USBI ( i n kHZ )="

499.

"LSB ( i n kHz )="

2.

"Bandwidth ( i n kHZ )="

501.5

"USB( i n kHz )="


Department of ECE Page 79
Digital Signal Processing Lab

498.5

"LSB ( i n kHZ )="

Fig. 13.1 Spectrum of DSB-SC signal

clc ;
clear ;
Vm =3; // am pli t u d e of m e s sag e s i g n a l i n V
Vc =5; // am pli t u d e of c a r r i e r s i g n a l i n V
m = Vm / Vc ; // mo d ula tio n i n d e x
disp ("mo d ula tio n i n d e x") ;
disp (m ,"=") ;
disp ("Upper Si d e ba n d F r e q u e n c y ( i n MHz)") ;
Fm =4; // F r e q u e n c y i n KHz
Fc =5; // F r e q u e n c y i n MHz
disp ( Fc +( Fm *10^( -3) ) ,"=") ;
disp ("Lower Si d e ba n d F r e q u e n c y ( i n MHz)") ;
disp ( Fc -( Fm *10^( -3) ) ,"=") ;
disp ("AMplitude of ea c h Si d e ba n d ( i n V)") ;

Department of ECE Page 80


Digital Signal Processing Lab

disp ( m * Vc /2 ,"=") ;
"mo d ula tio n i n d e x"

0.6

"="

"Upper Si d e ba n d F r e q u e n c y ( i n MHz)"

5.004

"="

"Lower Si d e ba n d F r e q u e n c y ( i n MHz)"

4.996

"="

"AMplitude of ea c h Si d e ba n d ( i n V)"

1.5

"="
RESULT: The modulating signal is modulated by high frequency carrier signal. The
amplitude modulated DSB-SC signal and its concerned spectrum is shown in fig 13.1

DISCUSSION:
1. Define amplitude modulation?
2. Differentiate between amplitude and angle modulated signal
3. What is frequency range of AM and FM signal

Department of ECE Page 81


Digital Signal Processing Lab

This Page is intentionally left blank

Department of ECE Page 82


Digital Signal Processing Lab

EXPERIMENT 14

AIM: To develop program for auto correlation and cross correlation for the given two
sequences: x1 = [1 2 3 4] and x2 = [4 3 2 1]

SOFTWARE USED: Scilab 6.1.0

THEORY:
Auto correlation function is a measure of similarity between a signal & its time delayed
version. It is represented with R(k).
The auto correlation function of x(n) is given by

Cross correlation:
Cross-correlation is a measure of similarity of two series as a function of the displacement of
one relative to the other. This is also known as a sliding dot product or sliding inner-product.
The cross-correlation is similar in nature to the convolution of two functions

PROGRAM FOR COMPUTING CROSS-CORRELATION OF TWO SEQUENCES

// Ca p tio n : Program to Compute t h e C r o s s c o r r e l a t i o nof a S e q u e n c e


//And v e r f i c a t i o n of c r o s s c o r r e l a t i o n p r o p e r t y
clc ;
clear ;
close ;
x = input ('E n t e r t h e F i r s t i n p u t S e q u e n c e :=') ;
y = input ('E n t e r t h e s e c o n d i n p u t S e q u e n c e :=')
mx = length ( x ) ;
my = length ( y ) ;
lx = input ('E n t e r t h e l o w e r i n d e x of f i r s t i n p u ts e q u e n c e :=')
ly = input ('E n t e r t h e l o w e r i n d e x of s e c o n d i n p u ts e q u e n c e :=')
hx = lx + mx -1;
n = lx :1: hx ;
x_fold = x($ : -1:1) ;
y_fold = y($ : -1:1) ;
nx = lx + ly ;

Department of ECE Page 83


Digital Signal Processing Lab

ny = nx + mx + my -2;
r = nx : ny ;
Rxy = convol (x , y_fold ) ;
Ryx = convol ( x_fold , y) ;
disp ( Rxy ,'C r o s s C o r r e l a t i o n Rxy [ n ] : =')
count =1;
subplot (2 ,1 ,1)
plot2d3 ('gnn',n , x)
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('I n p u t S e q u e n c e x [ n ]')
subplot (2 ,1 ,2)
plot2d3 ( 'gnn',r , Rxy )
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('C r o s s c o r r e l a t i o n S e q u e n c e Rxy [ n ]')

OUTPUT:
n t e r t h e F i r s t i n p u t S e q u e n c e :=[1 2 1 1]

E n t e r t h e s e c o n d i n p u t S e q u e n c e :=[1 1 2 1]

E n t e r t h e l o w e r i n d e x of f i r s t i n p u ts e q u e n c e :=0

E n t e r t h e l o w e r i n d e x of s e c o n d i n p u ts e q u e n c e :=0

1. 4. 6. 6. 5. 2. 1.

"C r o s s C o r r e l a t i o n Rxy [ n ] : ="

Department of ECE Page 84


Digital Signal Processing Lab

Figure 14.1: Input sequence, and cross correlated sequence

PROGRAM FOR COMPUTING AUTOCORRELATION FUNCTION

clc ;
clear ;
close ;
x = input ('E n t e r t h e i n p u t S e q u e n c e :=') ;
m = length ( x ) ;
lx = input ('E n t e r t h e l o w e r i n d e x of i n p u t s e q u e n c e:=')
hx = lx +m -1;
n = lx :1: hx ;
x_fold = x($ : -1:1) ;
nx = lx + lx ;
nh = nx + m +m -2;
r = nx : nh ;
Rxx = convol (x , x_fold ) ;
disp ( Rxx ,'Auto C o r r e l a t i o n Rxx [ n ] : =')
subplot (2 ,1 ,1)
plot2d3 ('gnn',n , x)
Department of ECE Page 85
Digital Signal Processing Lab

xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('I n p u t S e q u e n c e x [ n ]')
subplot (2 ,1 ,2)
plot2d3 ('gnn',r , Rxx )
xlabel ('n===>')
ylabel ('Amplitude−−>')
title ('Auto c o r r e l a t i o n S e q u e n c e Rxx [ n ]')
OUTPUT:
E n t e r t h e i n p u t S e q u e n c e :=[2 -1 3 4 1]

E n t e r t h e l o w e r i n d e x of i n p u t s e q u e n c e:=2

2. 7. 5. 11. 31. 11. 5. 7. 2.

"Auto C o r r e l a t i o n Rxx [ n ] : ="

Figure 14.2: Input sequence and auto correlated sequence

Department of ECE Page 86


Digital Signal Processing Lab

RESULT:
Input sequence and cross correlated sequence is shown in Fig 14.1 and input sequence and
auto correlated sequence is shown in Fig 14.2
DISCUSSION:
1. Write mathematical formula to find auto correlation?
2. Define auto correlation an cross correlation.
3. What is the difference between Auto correlation and cross correlation?
4. What is the length of the resultant sequence of auto correlation?
5. Give the properties of auto correlation.

Department of ECE Page 87

You might also like