0% found this document useful (0 votes)
13 views

Rajveer

Uploaded by

tanish180702
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)
13 views

Rajveer

Uploaded by

tanish180702
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/ 30

Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO

Jaipur- 302 022.

DSP LAB MANUAL

Lab Name : Digital Signal Processing

Lab Code : 5EC4-22

Branch : Electronics & Communications Engineering

SUBMITTED BY :
SUBMITTED TO :

JECRC EC DEPARTMENT Page 1


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

Department of Electronics & Communication


Jaipur Engineering College and Research Center, Jaipur

Index
S. No Contents Page No.
1 Motto of JECRC

2 Vision and Mission of the Institute

3 Vision and Mission of the Department

4 Program Educational Objectives (PEOs)

5 Program Outcomes (POs)

6 Program Specific Outcomes PSO of the Department

7 RTU Syllabus

8 Course Outcomes

9 CO/PO-PSO mapping

10 Content Beyond Syllabus

JECRC EC DEPARTMENT Page 2


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

Motto of JECRC

TEACH
TRAIN
&
TRANSFORM
FOR

• Contribution towards National Development


• Global Competencies among Students
• Incorporating a Value System
• Promotion to use of Technology

Vision of the Institute

To become a renowned centre of outcome based learning, and work towards academic,
JECRC EC DEPARTMENT Page 3
Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

professional, cultural and social enrichment of the lives of individuals and communities.

Mission of the Institute

• Focus on evaluation of learning outcomes and motivate students to inculcate research


aptitude by project based learning.
• Identify, based on informed perception of Indian, regional and global needs, areas of
focus and provide platform to gain knowledge and solutions.
• Offer opportunities for interaction between academia and industry.
• Develop human potential to its fullest extent so that intellectually capable and
imaginatively gifted leaders can emerge in a range of professions.

Vision of the Department

To contribute to the society through excellence in scientific and technical education, teaching and
research aptitude in Electronics and Communication Engineering to meet the needs of Global
Industry.

JECRC EC DEPARTMENT Page 4


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

Mission of the Department

M1: To equip the students with strong foundation of basic sciences and domain knowledge
of ECE, so that they are able to creatively their knowledge to the solution of problems
arising in their career path.

M2: To induce the habit of lifelong learning to continuously enhance overall performance.

M3: Students are able to communicate their ideas clearly and concisely so that they can
work in team as well as an individual.

M4: To make the students responsive towards the ethical, social, environmental and in
economic context for the society.

Program Educational Objectives

PEO1 To provide students with the fundamentals of engineering sciences with more
emphasis in Electronics & Communication Engineering by way of analysing
and exploiting electronics & communication challenges.

JECRC EC DEPARTMENT Page 5


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PEO2 To train students with good scientific and Electronics & Communication
Engineering knowledge so as to comprehend, analyse, design and create
electronics & communication based novel products and solutions for the real
life problems.
PEO3 To inculcate professional and ethical attitude, effective communication skills,
teamwork skills, multidisciplinary approach, entrepreneurial thinking and an
ability to relate Electronics & Communication Engineering with social issues.
PEO4 To provide students with an academic environment aware of excellence,
leadership, written ethical codes and guidelines, and the self-motivated life-
long learning needed for a successful Electronics & Communication
Engineering professional career.
PEO5 To prepare students to excel in electronics & communication based industry
and higher education by educating students in Electronics & Communication
Engineering field along with high moral values and knowledge.

Program Outcomes

PO1 Engineering Knowledge: Apply the knowledge of mathematics, science,


engineering fundamentals, and electronics & communication engineering
specialization to the solution of complex electronics and communication
engineering problems.

JECRC EC DEPARTMENT Page 6


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PO2 Problem Analysis: Identify, formulate, research literature, and analyse complex
electronics and communication engineering problems reaching substantiated
conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
PO3 Design/Development of Solutions: Design solutions for complex electronics
and communication 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.
PO4 Conduct Investigations of Complex Problems: Use research-based knowledge
and research methods including design of electronics and communication
engineering experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
PO5 Modern Tool Usage: Create, select, and apply appropriate techniques,
resources, and modern electronic engineering and IT tools including prediction
and modelling to complex electronics and communication engineering activities
with an understanding of the limitations.
PO6 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 electronics and
communication engineering practice.
PO7 Environment and Sustainability: Understand the impact of the professional
electronics and communication engineering solutions in societal and
environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.

JECRC EC DEPARTMENT Page 7


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PO8 Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the electronics and communication engineering
practice.
PO9 Individual and Team Work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex electronics and
communication 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.
P O 11 Project Management and Finance: Demonstrate knowledge and understanding
of the electronics and communication 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.
PO12 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
electronics and communication engineering changes.

Program Specific Outcomes

PSO1 Ability to develop knowledge for Robotics and its applications.


PSO2 Ability to apply the concepts of IoT for challenges of Real-World.

JECRC EC DEPARTMENT Page 8


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 1
AIM: Generation of continuous and discrete elementary signals (Periodic and non periodic)
using mathematical expression.

Software requirement: - SCI LAB

Theory: A wave is a disturbance that transfers energy from one place to another without
requiring any net flow of mass. Waves can be broadly separated into pulses and periodic waves.
A pulse is a single disturbance while a periodic wave is a continually oscillating motion. There is
a close connection between simple harmonic motion and periodic waves; in most periodic waves,
the particles in the medium experience simple harmonic motion.

Waves can also be separated into transverse and longitudinal waves. In a transverse wave, the
motion of the particles of the medium is at right angles (i.e., transverse) to the direction the wave
moves. In a longitudinal wave, such as a sound wave, the particles oscillate along the direction of
motion of the wave.

Surface waves, such as water waves, are generally a combination of a transverse and a
longitudinal wave. The particles on the surface of the water travel in circular paths as a wave
moves across the surface.

Periodic waves

A periodic wave generally follows a sine wave pattern, as shown in the diagram.

JECRC EC DEPARTMENT Page 9


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM CODE
//continous time cosine signal //discrete time cosine signal
t=-5:0.01:5; n = -20:.01:20;
y1=cos(t); y4=cos(n);
subplot(3,2,1); subplot(3,2,2);
plot2d3(t,y); plot2d3(n,y4);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('continous time cosine signal'); title('discrete time cosine signal');

//continous time sine signal //discrete time sine signal


y2=sin(t); y5=sin(n);
subplot(3,2,3); subplot(3,2,4);
plot2d3(t,y2); plot2d3(n,y5);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('continous time sine signal'); title('discrete time sine signal');

//continous time aperiodic signal //discrete time aperiodic signal


y3=sin(2*F*t*pi).*t; y6=cos(2*f*n*pi).*n;
subplot(3,2,5); subplot(3,2,6);
plot2d3(t,y3); plot2d3(n,y6);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('continous time aperiodic signal'); title('discrete time aperiodic signal');

Figure 2.2 Continuous and Discrete Time Elementary Signals

JECRC EC DEPARTMENT Page 10


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 2
AIM: Generation of Continuous and Discrete Unit Step Signal.
Software requirement: - SCI LAB
Unit step: A signal with magnitude one for time greater than zero. We can assume it as a dc
signal which got switched on at time equal to zero.

Unit step function is denoted by u (t). It is defined as u (t) =

Figure 2.3Continuous Time Unit Step Signal

• It is used as best test signal.


• Area under unit step function is unity

PROGRAM CODE

JECRC EC DEPARTMENT Page 11


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

t=-10:1:10; n=-10:1:10;
y1=[zeros(1,10),ones(1,11)]; y7=[zeros(1,10),ones(1,11)];
subplot(4,3,1); subplot(4,3,7);
plot2d3(t,y1); plot2d3(n,y7);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('Continuous Unit Step Function'); title('discrete Unit Step u(n) Function');

y2=[zeros(1,16),ones(1,5)]; y8=[zeros(1,16),ones(1,5)];
subplot(4,3,2); subplot(4,3,8);
plot2d3(t,y2); plot2d3(n,y8);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('Continuous Unit Step u(t-6) Function'); title('discrete Unit Step u(n-6) Function');

y3=[zeros(1,4),ones(1,17)]; y9=[zeros(1,4),ones(1,17)];
subplot(4,3,3); subplot(4,3,9);
plot2d3(t,y3); plot2d3(n,y9);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('Continuous Unit Step u(t+6) Function'); title('discrete Unit Step u(n+6) Function');

y4=[zeros(1,6),ones(1,15)]; y10=[zeros(1,6),ones(1,15)];
subplot(4,3,4); subplot(4,3,10);
plot2d3(t,y4); plot2d3(n,y10);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('Continuous Unit Step u(-t+4) Function'); title('discrete Unit Step u(-n+4) Function');

y5 = y3 - y2; y11 = y9 - y8;


subplot(4,3,5); subplot(4,3,11);
plot2d3(t,y5); plot2d3(n,y11);
xlabel('Time'); xlabel('Time');
ylabel('Magnitude'); ylabel('Magnitude');
title('Continuous Unit Step u(t+6)-u(t-6) title('discrete Unit Step u(n+6)-u(n-6) Function');
Function');

y12 = y9 + y8;
y6 = y3 + y2; subplot(4,3,12);
subplot(4,3,6); plot2d3(n,y12);
plot2d3(t,y6); xlabel('Time');
xlabel('Time'); ylabel('Magnitude');
ylabel('Magnitude'); title('discrete Unit Step u(n+6)+u(n-6) Function');
title('Continuous Unit Step u(t+6)+u(t-6)
Function');

JECRC EC DEPARTMENT Page 12


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 3
AIM: Adding and subtracting two given signals (continuous as well as discrete signals).

Software requirement: - SCI LAB


clc; //discrete signal
//continuous signal n=0:1:30;
t = 0:0.001:30; a=n;
y1 = t; b=2*n;
y2 = 2*t; //First Signal
//First Signal subplot(4,2,5);
subplot(4,2,1); plot2d3(n,a);
plot2d3(t,y1); xlabel('time');
xlabel('time'); ylabel('magnitude');
ylabel('magnitude'); title('First Signal');
title('First Signal'); //Second Signal
//Second Signal subplot(4,2,6);
subplot(4,2,2); plot2d3(n,b);
plot2d3(t,y2); xlabel('time');
xlabel('time'); ylabel('magnitude');
ylabel('magnitude'); title('Second Signal');
title('Second Signal'); c=a+b;
y3 = y1+y2; d=a-b;
y4 = y1-y2; //Addition
//Addition subplot(4,2,7);
subplot(4,2,3); plot2d3(n,c);
plot2d3(t,y3); xlabel('time');
xlabel('time'); ylabel('magnitude');
ylabel('magnitude'); title('Addition');
title('Addition'); //subtraction
//subtraction subplot(4,2,8);
subplot(4,2,4); plot2d3(n,d);
plot2d3(t,y4); xlabel('time');
xlabel('time'); ylabel('magnitude');
ylabel('magnitude'); title('Subtraction');
title('Subtraction');

Figure (Expected output):


JECRC EC DEPARTMENT Page 13
Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 4

AIM: Continuous and Discrete Time Convolution (Using Basic Definition).


Software requirement: - SCI LAB

Theory: A convolution is an integral that expresses the amount of overlap of one function as it is
shifted over another function. It therefore "blends" one function with another. For example, in
synthesis imaging, the measured dirty map is a convolution of the "true" CLEAN map with the
dirty beam (the FOURIER TRANSFORM of the sampling distribution). The convolution is
sometimes also known by its German name, faltung ("folding").

Abstractly, a convolution is defined as a product of functions and that are objects in the
algebra of SCHWARTZ FUNCTIONS in. Convolution of two functions and over a finite
range is given by

Where the symbol denotes convolution of and .

Convolution is more often taken over an infinite range,

PROGRAM CODE

JECRC EC DEPARTMENT Page 14


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

(4A) (4B) (4C)


x=input('enter first sequence'); x = input('enter the first
b1=input('enter the lower limit'); seq');
u1=input('enter the upper limit'); t1=-5:1:0 N1 = length(x);
x1=b1:1:u1; t2=0:1:2; n1 = 0:1:N1-1;
h=input('enter second sequence'); t3=2:1:5; subplot(2,2,1);
b2=input('enter the lower limit'); plot2d3(n1,x);
u2=input('enter the upper limit'); h1=zeros(size(t1)); xlabel('time');
h1=b2:1:u2; h2=ones(size(t2)); ylabel('mag');
b=b1+b2; h3=zeros(size(t3)); title('seq of x');
u=u1+u2;
a=b:1:u; t=[t1 t2 t3]; h = input('enter the second
m=length(x); h=[h1 h2 h3]; seq');
n=length(h); subplot(3,1,1); N2 = length(h);
X=[x,zeros(1,n)]; plot2d3(t,h); n2 = 0:1:N2-1;
subplot(2,2,1); xlabel('time'); subplot(2,2,2);
disp('x(n) is:'); ylabel('magnitude'); plot2d3(n2,h);
disp(x); xlabel('time');
plot2d3(x1,x); a1=-5:1:0; ylabel('mag');
xlabel('n'); a2=0:1:4; title('seq of h');
ylabel('x(n)'); a3=4:1:6;
title('first squence'); y=conv(x,h);
grid on; x1=zeros(size(a1)); n = 0:1:N1+N2-2;
H=[h,zeros(1,m)]; x2=ones(size(a2)); subplot(2,2,[3 4]);
subplot(2,2,2); x3=zeros(size(a3)); plot2d3(n,y);
disp('h(n) is;'); xlabel('time');
disp(h); a=[a1 a2 a3]; ylabel('mag');
plot2d3(h1,h); x=[x1 x2 x3]; title('convolution');
xlabel('n'); subplot(3,1,2);
ylabel('h(n)'); plot2d3(a,x);
title('second sequence'); xlabel('time');
grid on; ylabel('magnitude');
for i=1:n+m-1
Y(i)=0;
for j=1:m; c=conv(x2,h2);
if((i-j+1)>0) subplot(3,1,3);
Y(i)=Y(i)+(X(j)*H(i-j+1)); plot2d3(c);
else xlabel('time');
end ylabel('magnitude');
end
end
subplot(2,2,[3 4]);
disp('y(n) is:');
disp(Y);
plot2d3(a,Y);
xlabel('n');
ylabel('Y(n)');
title('output sequence');
grid on;

JECRC EC DEPARTMENT Page 15


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 5
AIM: Checking Linearity and Time variance property of a system using convolution, shifting.

Software requirement: - SCI LAB

Theory: Convolution is a mathematical operation used to express the relation between input
and output of an LTI system. It relates input, output and impulse response of an LTI system as

y(n)=x(n)∗h(n)

Where y (n) = output of LTI

x (n) = input of LTI

h (n) = impulse response of LTI

Discrete Convolution y(n)=x(n)∗h(n) = By using convolution we can find zero state response of
the system.PROGRAM CODE

clc; n2=0:M-1;
//Linearity and Time variance subplot(312);
x1=input('Enter the first sequence x1(n) = '); stem(n2,x2);
x2=input('Enter the second sequence x2(n) = ');
grid on;
L=length(x1);
M=length(x2); xlabel('n2--->');
N=L+M-1; yn=conv(x1,x2); ylabel('amplitude--->');
disp(‘The values of yn are= ‘);
disp(yn);
title('Second sequence');
n1=0:L-1; n3=0:N-1; subplot(313);
subplot(311); stem(n3,yn);
stem(n1,x1); grid on; xlabel('n3--->'); ylabel('amplitude---
grid on; >');
xlabel('n1--->'); title('Convolved output');
ylabel('amplitude--->');
title('First sequence');

n2=0:M-1;

JECRC EC DEPARTMENT Page 16


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 6

AIM: To generate and verify random sequences with arbitrary distributions, means and
variances for: (a) Rayleigh
distribution (b) Normal
distributions: N(0,1) (c) Poisson
distributions: N(m, x)

Software requirement: - SCI LAB

Theory:(a)The Rayleigh distribution- it is a special case of the WEIBULL DISTRIBUTION.


If A and B are the parameters of the Weibull distribution, then the Rayleigh distribution with
parameter b is equivalent to the Weibull distribution with parameters A=21/2 b and B = 2.

If the component velocities of a particle in the x and y directions are two independent
normal random variables with zero means and equal variances, then the distance the
particle travels per unit time is distributed Rayleigh.

In communications theory NAKAGAMI DISTRIBUTION, RICIAN DISTRIBUTION,


and Rayleigh distributions are used to model scattered signals that reach a receiver by
multiple paths. Depending on the density of the scatter, the signal will display different
fading characteristics. Rayleigh and Nakagami distributions are used to model dense
scatters, while Rician distributions model fading with a stronger line-of-sight. Nakagami
distributions can be reduced to Rayleigh distributions, but give more control over the
extent of the fading.

(b) The Normal distributions-

Figure 6.1 Normal Probability


Distribution Graph
JECRC EC DEPARTMENT Page 17
Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

A normal distribution in a VARIATE with MEAN and VARIANCE is a statistic


distribution with probability density function

(1)

on the domain . While statisticians and mathematicians uniformly use the term
"normal distribution" for this distribution, physicists sometimes call it a Gaussian
distribution and, because of its curved flaring shape, social scientists refer to it as the
"bell curve."

The so-called "standard normal distribution" is given by taking and in a


general normal distribution. An arbitrary normal distribution can be converted to
a ,standard normal distribution by changing variables to , sO
,yielding

PROGRAM CODE

//normal distribution //rayleigh distribution //poission distribution


x = -5:0.01:5; x = -5:1:15; x = -5:1:15;
y1 = (normpdf(x,0,1)); y1 = (poisspdf(x,4)); y1 = (raylpdf(x,4));
y2 = (normpdf(x,0.1,2)); y2 = (poisspdf(x,2)); y2 = (raylpdf(x,2));
y3 = (normpdf(x,0,0.5)); y3 = (poisspdf(x,1)); y3 = (raylpdf(x,1));
subplot(3,1,1); subplot(3,1,2); subplot(3,1,3);
plot2d3(x,y1,'.',x,y2,'-',x,y3,'*' plot2d3(x,y1,'.',x,y2,'-',x,y3,'*' plot2d3(x,y1,'.',x,y2,'-',x,y3,'*'
); ); );
xlabel('value of x'); xlabel('value of x'); xlabel('value of x');
ylabel('value of y'); ylabel('value of y'); ylabel('value of y');
title('normal distribution'); title('rayleigh distribution'); title('poission distribution');

JECRC EC DEPARTMENT Page 18


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 7

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

Software requirement: - SCI LAB

Theory: Basic equation to find the DFT of a sequence is given below.

Basic equation to find the IDFT of a sequence is given below.

PROGRAM CODE

JECRC EC DEPARTMENT Page 19


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

//pdf
xn=input('Enter the sequence x(n)'); % Find the phases of individual DFT points
ln=length(xn); % plot the magnitude sequence
xk=zeros(1,ln); t=0:ln-1;
xk=zeros(1,ln); subplot(223);
stem(t,phase);
%DFT of sequence ylabel ('Phase');
xlabel ('K');
for k=0:ln-1 title ('Phase Response');
for n=0:ln-1
xk(k+1)=xk(k+1)+ %IDFT of the sequence
(xn(n+1)*exp((i)*2*pi*k*n/ln)); for n=0:ln-1
end for k=0:ln-1 ixk(n+1)=ixk(n+1)+
end (xk(k+1)*exp(i*2*pi*k*n/ln));
%Plotting input sequence end
end
t=0:ln-1; ixk=ixk./ln;
subplot(221); %code block to plot the input sequence
stem(t,xn); t=0:ln-1;
ylabel ('Amplitude'); subplot(224);
xlabel ('Time Index'); stem(t,ixk);
title('Input Sequence'); ylabel ('Amplitude');
magnitude=abs(xk); xlabel ('Time Index');
title ('IDFT sequence');
% plot the magnitude response
t=0:ln-1; subplot(222);
stem(t,magnitude);
ylabel ('Amplitude');
xlabel ('K');
title('Magnitude Response');subplot(2,1,2);
phase=angle(xk);

Output:

Xn=[1 2 3 4 5]

Xk = 15,-2.50+3.44i,-2.50+0.81i,-2.49-0.81i,-2.49-3.44i

JECRC EC DEPARTMENT Page 20


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 8

AIM: N-point FFT algorithm.

Software requirement: - SCI LAB

Theory: DFT of a sequence

Where N= Length of sequence. K= Frequency Coefficient. n = Samples in time domain.

FFT: -Fast Fourier transform. There are two methods.

1. Decimation in time (DIT ) FFT.

2. Decimation in Frequency (DIF) FFT.

Why we need FFT?

The no of multiplications in DFT = N2.

The no of Additions in DFT = N (N-1).

For FFT

The no of multiplication = N/2 log 2N.

The no of additions = N log2 N.

PROGRAM CODE

JECRC EC DEPARTMENT Page 21


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

close all; xlabel('n---->');


x=input('Enter the sequence : ') ylabel('magnitude');
N=length(x) title('magnitude response');
xK=fft(x,N) subplot (2,2,3);
xn=ifft(xK) stem(n,angle(xK));
n=0:N-1; xlabel('n---->');
subplot (2,2,1); ylabel('phase');
stem(n,x); title('Phase responce');
xlabel('n---->'); subplot (2,2,4);
ylabel('amplitude'); stem(n,xn);
title('input sequence'); xlabel('n---->');
subplot (2,2,2); ylabel('amplitude');
stem(n,abs(xK));
xlabel('n---->');
ylabel('magnitude');
title('magnitude response');
subplot (2,2,3);
stem(n,angle(xK));
xlabel('n---->');
ylabel('phase');

Figure 8.1 DFT Sequence

JECRC EC DEPARTMENT Page 22


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 9

AIM: To implement Circular convolution.

Software requirement: - SCI LAB

PROGRAM CODE

Clc;
xl = input ('Enter the First Sequence to be xlabel('Time');
convoluted:'); ylabel('Amplitude');
11 = length(x1); title('First Sequence');
x2 = input ('Enter the Second Sequence to be subplot(312);
convoluted:'); stem(x2);
12 = length(x2); xlabel('Time');
13 = 11 + 12 -1; ylabel('Amplitude');
xl =[x1 ,zeros( 1,13-11)]; title('First Sequence');
x2= [x2,zeros(1,13-l2)]; subplot(313);
disp('The Input Squence:'); stem(f);
x1,x2 f = cconv(x1,x2,13); xlabel('Time');
disp('The Circular Convoluted Sequence is:'); ylabel('Amplitude');
disp(f); title('Circular Convoluted sequence');
subplot(311);
stem(x1);

OUTPUT

xl = 1 2 0 0
x2 = 1 2 4 0

The Circular Convoluted Sequence is: 1 488

Figure (Expected output):

JECRC EC DEPARTMENT Page 23


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 10

AIM: MATLAB code for implementing z-transform.

Software requirement: - SCI LAB

PROGRAM CODE
Clc;
%Compute the Z-transform of sin(n)
syms n
f = sin(n);
ztrans(f)

ans = (z*sin(1))/(z^2 - 2*cos(1)*z + 1)

% Compute the Z-transform of exp(m+n)


syms m n
f = exp(m+n);
ztrans(f)

ans = (z*exp(m))/(z - exp(1))

%Compute the Z-transform of symbolic functions


syms f1(x) f2(x) a b
f1(x) = exp(x);
f2(x) = x;
ztrans([f1 f2],x,[a b])

ans = [ a/(a - exp(1)), b/(b - 1)^2]

JECRC EC DEPARTMENT Page 24


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 11

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

Software requirement: - SCI LAB

Theory:

1. Butterworth lter
Syntax [n,Wn] = buttord(Wp,Ws,Rp,Rs)
Description
calculates the minimum order of a digital or analog Butterworth filter required to meet a set of
filter design
Parameter Descrip on
s

Wp Passband corner frequency

Ws Stopband corner frequency

Rp Passband ripple, in decibels

Rs Stopband attenuation, in decibels

n the lowest order the proposed Butterworth filter

Wn corresponding cut-off frequency

2. Butter

Syntax
[b,a] = butter(n,Wn)
[b,a] = butter(n,Wn,'ftype’)
[b,a] = butter(n,Wn,'s’)
Description : Designs lowpass, bandpass, highpass, and bandstop digital and analog Butterworth
filters. Butterworth filters are characterized by a magnitude response that is maximally flat in the
passband and monotonic overall.

JECRC EC DEPARTMENT Page 25


ti
fi
Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM CODE

clc;
clear all; clc; clear all; close all;
close all; format long;
format long; % Program fopr Butterworth HPF
% Program for Butterwoth LPF wp=input('Please enter the first pass band
wp=input('Please enter the first pass band frequency (Hz): ');
frequency (Hz): '); ws=input('Please enter the first stop band
ws=input('Please enter the first stop band frequency (Hz): ');
frequency (Hz): '); rp=input('Please enter the pass band ripple: ');
rp=input('Please enter the pass band ripple: '); rs=input('Please enter the stop band ripple: ');
rs=input('Please enter the stop band ripple: '); fs=input('Please enter the sampling
fs=input('Please enter the sampling frequency: (Hz)');
frequency: (Hz)'); w1=2*wp/fs;
w1=2*wp/fs; w2=2*ws/fs;
w2=2*ws/fs; [n,wn]=buttord(w1,w2,rp,rs);
[n,wn]=buttord(w1,w2,rp,rs); [b,a]=butter(n,wn,'high');
[b,a]=butter(n,wn) w=0:0.01:pi;
w=0:0.01:pi; [h,om]=freqz(b,a,w);
[h,om]=freqz(b,a,w); m=20*log10(abs(h));
m=20*log10(abs(h)); an=angle(h);
an=angle(h); subplot(2,1,1); plot(om/pi,m);
subplot(2,1,1); plot(om/pi,m); ylim([-300 50]);
ylim([-300 50]); ylabel('gain in dB');
ylabel('gain in dB'); xlabel('Normalised frequency');
xlabel('Normalised frequency'); subplot(2,1,2);plot(om/pi,an); ylabel('Phase in
subplot(2,1,2);plot(om/pi,an); Radian’); xlabel('Normalised frequency');
ylabel('Phase in Radian');
xlabel('Normalised frequency');

JECRC EC DEPARTMENT Page 26


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

PROGRAM 12

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

Software requirement: - SCI LAB

Theory:

FIR filters are digital filters with finite impulse response. They are also known as non-recursive
digital filters as they do not have the feedback. An FIR filter has two important advantages over
an IIR design:

Firstly, there is no feedback loop in the structure of an FIR filter. Due to not having a feedback
loop, an FIR filter is inherently stable. Meanwhile, for an IIR filter, we need to check the
stability. Secondly, an FIR filter can provide a linear-phase response. As a matter of fact, a linear-
phase response is the main advantage of an FIR filter over an IIR design otherwise, for the same
filtering specifications; an IIR filter will lead to a lower order.

1. Window design method


2. Frequency Sampling method
3. Weighted least squares design

PROGRAM CODE

JECRC EC DEPARTMENT Page 27


Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

clc;
clear all; %Band Pass filter
close all; wn=[wp ws];
% Program code for FIR Butterworth filter b=fir1(n,wn, ‘band', y);
using Rectangular window [h,o]=freqz(b,1,256);
fp=input('Please enter the pass band frequency m=20*log10(abs(h));
(Hz): '); subplot(2,2,3); plot(o/pi,m);
fs=input('Please enter the stop band frequency ylim([-120 20]);
(Hz): '); ylabel('Gain in dB');
rp=input('Please enter the pass band ripple: '); xlabel('Normalised frequency');
rs=input('Please enter the stop band ripple: '); title('Band pass filter');
sf=input('Please enter the sampling frequency:
(Hz)'); % Band stop filter
wp=2*fp/sf; b=fir1(n,wn,'stop',y);
ws=2*fs/sf; [h,o]=freqz(b,1,256);
num=-20*log10(sqrt(rp*rs))-13; m=20*log10(abs(h));
dem=14.6*(fs-fp)/sf; subplot(2,2,4); plot(o/pi,m);
n=ceil(num/dem); ylim([-15 5]);
n1=n+1; ylabel('Gain in dB');
if(rem(n,2)~=0) xlabel('Normalised frequency');
n1=n; title('Stop pass filter');
n=n-1;
end
y=rectwin(n1)

%Low pass filter


b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1); plot(o/pi,m);
ylim([-120 20]);
ylabel('Gain in dB');
xlabel('Normalised frequency');
title('Low pass filter');
%High pass filter
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);
JECRC EC DEPARTMENT Page 28
Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

clc;
clear all; %Band Pass filter
close all; wn=[wp ws];
fp=input('Please enter thepass band b=fir1(n,wn, ‘band', y);
frequency (Hz): '); [h,o]=freqz(b,1,256);
fs=input('Please enter the stop band m=20*log10(abs(h));
frequency (Hz): '); subplot(2,2,3); plot(o/pi,m);
rp=input('Please enter the pass band ylim([-120 20]);
ripple: '); ylabel('Gain in dB');
rs=input('Please enter the stop band xlabel('Normalised frequency');
ripple: '); title('Band pass filter');
sf=input('Please enter the sampling % Band stop filter
frequency: (Hz)'); b=fir1(n,wn,'stop',y);
beta=input('Please enter the value of [h,o]=freqz(b,1,256);
beta'); m=20*log10(abs(h));
wp=2*fp/sf; subplot(2,2,4); plot(o/pi,m);
ws=2*fs/sf; ylim([-15 5]);
num=-20*log10(sqrt(rp*rs))-13; ylabel('Gain in dB');
dem=14.6*(fs-fp)/sf; xlabel('Normalised frequency');
n=ceil(num/dem); title('Stop pass filter');
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=kaiser(n1,beta);

%Low pass filter


b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1); plot(o/pi,m);
ylim([-120 20]);
ylabel('Gain in dB');
xlabel('Normalised frequency');
title('Low pass filter');
%High pass filter
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
JECRC EC DEPARTMENT Page 29
Jaipur Engineering college and research centre, Shri Ram ki Nangal, via Sitapura RIICO
Jaipur- 302 022.

JECRC EC DEPARTMENT Page 30

You might also like