0% found this document useful (0 votes)
26 views23 pages

DSP File

The document is a practical file for Digital Signal Processing submitted by a Bachelor of Technology student in Electronics and Communication Engineering. It covers the introduction to MATLAB, its applications, and various experiments related to signal processing, including signal functions, operations, convolution, and transformations. Each experiment includes aims, MATLAB code, and outputs demonstrating the results of the implemented functions.

Uploaded by

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

DSP File

The document is a practical file for Digital Signal Processing submitted by a Bachelor of Technology student in Electronics and Communication Engineering. It covers the introduction to MATLAB, its applications, and various experiments related to signal processing, including signal functions, operations, convolution, and transformations. Each experiment includes aims, MATLAB code, and outputs demonstrating the results of the implemented functions.

Uploaded by

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

PRACTICAL FILE OF

DIGITAL SIGNAL PROCESSING

BACHELOR OF TECHONOLOGY

(Electronics and Communication Engineering)

B.TECH ECE 3RD YEAR

SUBMITTED BY SUBMITTED TO

NAME : VRITIKA CHAUDHARY PROF. SIMRANJEET KAUR

URN : 2203775

CRN : 2217090

SEC. : ECB (B1)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

GURU NANAK DEV ENGINEERING COLLLEGE LUDHIANA


(An Autonomous College Under UGC ACT)
INDEX
SR.NO. AIM DATE PAGE NO. SIGNATURE
INDEX
SR.NO. AIM DATE PAGE NO. SIGNATURE
AIM: INTRODUCTION TO MATLAB

MATLAB: MATLAB is a software package for high performance numerical computation and
visualization. It provides on interactive environment with hundreds of built in functions for
technical computation, graphics and animations. MATLAB stands for MATrixLABoratory.
High-Performance Numerical Computation: MATLAB excels at handling complex mathematical
calculations quickly and accurately. It is often used for solving systems of linear equations,
performing matrix operations, and executing algorithms that require significant computational
power.

Visualization: MATLAB provides powerful tools for creating a wide range of plots and graphics.
This includes 2D and 3D plots, histograms, scatter plots, and other types of visualizations that
help in understanding and interpreting data.

Interactive Environment: MATLAB offers an interactive workspace where users can write and
execute code, visualize results, and modify variables in real-time. This environment is conducive
to both development and testing of algorithms.

Built-in Functions: MATLAB comes with hundreds of pre-written functions that simplify
technical computations. These functions cover areas such as linear algebra, statistics, signal
processing, and control systems.

Technical Computation: This encompasses tasks like solving mathematical problems, running
simulations, and analyzing data. MATLAB's built-in functions and toolboxes (additional sets of
functions) support a wide range of technical disciplines.

Graphics and Animations: MATLAB’s graphics capabilities allow users to create detailed plots
and charts. It also supports animations, which are useful for visualizing dynamic systems or
changes over time.

MATLAB stands for MATrix LABoratory. The name reflects its origins and core functionality:
MATrix: MATLAB’s primary data structure is the matrix, and many of its functions are
designed to operate on matrices.

LABoratory: Indicates that MATLAB is a tool for experimentation and exploration, akin to a
virtual laboratory where users can test and refine their mathematical models and algorithms.
Overall, MATLAB is widely used in academia, research, and industry for tasks that involve
mathematical computation, data analysis, and visualization.

MATLAB's built in functions provide excellent tools for linear algebraic computations data
analysis, signal processing, optimization, numerical solution of scientific computations. There
are numerous functions for two dimensional and three dimensional graphics as well as for
animations. The basic building block of MATLAB is matrix. The fundamental data type is array,
vector, scalar, real matrix and complex matrix are all automatically handled as special cases of
have data types. The vectorised commands or codes run much faster in MATLAB.

• MATLAB Desktop: This is where the MATLAB puts us when we launch it. MATLAB
desktop by default consists of following sub-windows:

• Command Window: This is the main window. It is characterized by MATLAB command


prompt(>>). All commands including this for running user written programs are typed in this
window at MATLAB prompt in MATLAB7; this window is part of MATLAB window that
contains three other smallest windows.

• Current Directory: This is where all files from the current directory are listed. We can do
file navigation here to see the options. Click the right button of mouse after selecting a file.
We can run M-files, remove them, delete them etc.

• Work Space: This sub-window lists all variables that we have generated so far and shows
their types and sizes. We can do various things with phase variables such as plotting and then
using the right button on the mouse to select our option.
• Command History: All command typed on MATLAB prompt in the command window yet
recorded, even a cross multiple session in this window. We can select a set of commands
from this window and create an M-file with right click of mouse.

• Figure Window: The output of all graphics, commands typed in the commands window are
flushed to the graphics or figure window, a separate gray window with white background
colour. The user can create as many figure windows as the system memory will allow.

• Editor Window: This is where we write, edit, create and save our programs in files called
M-files by using any text editor to carry out these tasks. On most systems MATLAB
provides its own built in editor. However we can use our editor by typing the standard file
editing commands that we normally use on our system.

APPLICATIONS OF MATLAB:-

• MATLAB is widely used to perform various mathematical tasks such sum, sine, cosine, complex
arithmetic, Fourier transformation, Laplace transformation, differential equation solution, matrix
inversion, etc.

• MATLAB is used to design and analyze various types of control systems from control systems
used in room heaters to large industrial robotic systems.

• MATLAB is also used in digital image and signal processing.

• MATLAB is used in research and development of wireless communication systems. It helps to


reduce development time, eliminate design issues, easy testing and verification, etc.

• MATLAB is also used to design various types of embedded systems like automobiles, washing
machines, printers, etc. MATLAB allows to generate codes that can run on hardware.

• MATLAB is used in the field of mechatronics to design and simulate various electromechanical
systems.

• MATLAB is used in field of computational finance to analyze, study, and model the financial
data. It allows to estimate risks in investment, insurance, and more.
• MATLAB is also used to study biological data to understand relationships between various
biological systems.

• MATLAB has a wide range of applications in the field of robotics. It is used from initial
modeling to final implementation of robots and automatic machines.

• MATLAB is also used in machine learning and deep learning to develop various learning models
without having proper knowledge of coding.

• In electrical systems, MATLAB is used to power flow and motor control applications. It is also
used to develop algorithms to improve energy efficiency, provide protection against faults, etc.

ONLINE HELP

• Online Documentation: MATLAB provides online help for all its built in functions and
programming language constructs such as help, lookfor, helpdesk and helpwin.
• Demo: MATLAB has a demonstration program that shows many of its features which
includes type demo at MATLAB prompt to invoke demonstration programs and follow
the instruction on the screen.
EXPERIMENT NO. 1
AIM: To develop elementary signal function modules (m-files) for unit sample, unit step,
exponential and unit ramp sequences.

n= -5:5
%UNIT IMPULSE FUNCTION
x=[zeros(1,5),ones(1,1),zeros(1,5)]
subplot(2,4,1)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('UNIT IMPULSE created by 2203775')
%UNIT STEP FUNCTION
x=[zeros(1,5),ones(1,6)]
subplot(2,4,2)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('Unit Step created by 2203775')
%UNIT RAMP SEQUENCE
x2=0:5
x=[zeros(1,5),x2]
subplot(2,4,3)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('Unit Ramp created by 2203775')
% EXPONENTIAL FUNCTION
x=exp(n)
subplot(2,4,4)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('EXPONENTIAL FUNCTION created by 2203775')

SOLUTION:
n = -5 -4 -3 -2 -1 0 1 2 3 4 5
x= 0 0 0 0 0 1 0 0 0 0 0
x= 0 0 0 0 0 1 1 1 1 1 1
x2 = 0 1 2 3 4 5
x=0 0 0 0 0 0 1 2 3 4 5
x = 0.0067 0.0183 0.0498 0.1353 0.3679 1.0000 2.7183 7.3891 20.0855 54.5982
148.4132
EXPERIMENT NO. 2
AIM: To develop program modules based on operation on sequences like signal shifting,
signal folding, signal addition and signal multiplication.

%Signal Operation
n=0:4
x1=input('enter the first sequence=')
x2=input('enter the second sequence=')
subplot(2,3,1)
stem(n,x1)
xlabel('n')
ylabel('x1')
title('1st sequence created by 2203773')
subplot(2,3,2)
stem(n,x2)
xlabel('n')
ylabel('x2')
title('2nd sequence created by 2203773')

%Signal Addition
x=x1+x2
subplot(2,3,3)
stem(n,x)
xlabel('n')
ylabel('x')
title('addition created by 2203773')

%Signal Multiplication
x=x1.*x2
subplot(2,3,4)
stem(n,x)
xlabel('n')
ylabel('x')
title('multiplication created by 2203773')

%Signal Folding
n1=-n
p=1:5
subplot(2,3,5)
stem(n1,p)
xlabel('n1')
ylabel('p')
title('folding created by 2203773')

%Signal Shifting
N=length(x1)
q = 2:N + 1
subplot(2,3,6)
stem(q,x1)
xlabel('q')
ylabel('x1')
title('shifting created by 2203773')

SOLUTION:
n=0 1 2 3 4
enter the first sequence = [5 6 7 8 9]

x1 = 5 6 7 8 9

enter the second sequence = [7 8 5 7 8]

x2 = 7 8 5 7 8

x = 12 14 12 15 17
x = 35 48 35 56 72

n1 = 0 -1 -2 -3 -4

p=1 2 3 4 5

N=5

q=2 3 4 5 6
EXPERIMENT NO. 3
AIM: To develop a program to find a linear convolution and correlation of two discrete
time sequences.

x=input ('enter input 1')


y=input ('enter input 2')
subplot (2,2,1)
stem(x)
xlabel('n')
ylabel('x')
title ('input 1')
subplot (2,2,2)
stem(y)
xlabel('n')
ylabel ('y')
title ('input 2')
z=conv(x,y)
subplot(2,2,3)
stem(z)
xlabel('n')
ylabel('z')
title ('discrete convolution created by Roll No. 2203775')
w=xcorr(x,y)
subplot(2,2,4)
stem(w)
xlabel('n')
ylabel('w')
title ('discrete correlation created by Roll No.2203775')
OUTPUT:

enter input 1[3 2 1 0]

x=3 2 1 0

enter input 2 [3 4 6 7]

y=3 4 6 7

z=9 18 29 37 20 7 0

w = 21 32 31 23 10 3 0
EXPERIMENT NO. 4
AIM: To develop a program to find a linear convolution using z - transform:

syms z n
x1=(1/2).^n
x2=(1/3).^n
f1=ztrans(x1)
f2=ztrans(x2)
y1=f1.*f2
f3=iztrans(y1)

OUTPUT:

x1 = (1/2)^n

x2 = (1/3)^n

f1 = z/(z - 1/2)

f2 = z/(z - 1/3)

y1 = z^2/((z - 1/2)*(z - 1/3))

f3 = 3*(1/2)^n - 2*(1/3)^n
EXPERIMENT NO. 5
AIM: To develop a program for computing inverse z- transform:

syms z m
x=(-1)^m
f=ztrans(x,z)
iztrans(f,m)

OUTPUT:

x = (-1)^m

f = z/(z + 1)

ans = (-1)^m
EXPERIMENT NO. 6
AIM: To develop a program module to perform DFT and IDFT operation on discrete time
sequence:

x=input('enter the sequence x(n)=')


N=length(x)
n=0:1:N-1
k=0:1:N-1
xk=fft(x,N)
subplot(2,2,1)
stem(n,x)
xlabel('n')
ylabel('amplitude')
title('input sequence x(n)')
subplot(2,2,2)
stem(k,xk)
xlabel('k')
ylabel('amplitude')
title('DFT of input sequence:x(n)')
xn=ifft(xk,N)
subplot(2,2,3)
stem(n,xn)
xlabel('n')
ylabel('amplitude')
title('IDFT of input sequence:x(k)')

OUTPUT:

enter the sequence x(n)= [5 6 7 8 9 10]

x=5 6 7 8 9 10

N= 6
n= 0 1 2 3 4 5

k= 0 1 2 3 4 5

xk = Columns 1 through 3

45.0000 + 0.0000i -3.0000 + 5.1962i -3.0000 + 1.7321i

Columns 4 through 6

-3.0000 + 0.0000i -3.0000 - 1.7321i -3.0000 - 5.1962i

xn = 5 6 7 8 9 10
EXPERIMENT NO. 7
AIM: To develop a program to find circular convolution of to sequences using DFT and
IDFT method:
x=input('1st seq');
y=input('2nd seq');
n1=length(x);
n = 0:n1-1;
subplot(2,2,1);
stem(n,x);
xlabel('n');
ylabel('x');
title('1st seq x(n)');
n2=length(y);
m = 0:n2-1;
subplot(2,2,2);
stem(m,y) xlabel('n');
ylabel('y');
title('2nd seq (x(n)');
if n1>n2;
xk = fft(x,n1);
yk = fft(x,n1);
else xk= fft(x,n2);
yk= fft(y,n2);
end;
zk = xk.*yk
z=ifft(zk)
n3=length(z)
s = 0:n3-1
subplot(2,2,3);
stem(s,z);
xlabel('n');
ylabel('z');
title('circular convolution of x(n)&y(n)');

OUTPUT: -
1st seq[1 -1 -2 3 -1]
2nd seq[1 2 3]
zk = 0.0000 + 0.0000i -8.4549 - 2.5101i -14.0451 -27.8379i -14.0451 +27.8379i -8.4549 +
2.5101i
z = -9.0000 11.0000 -9.0000 11.0000 -4.0000
n3 = 5
s=0123 4
EXPERIMENT NO: 8
AIM: To develop program for finding magnitude and phase response of LTI system
described by system function H (z):-

% program to find the magnitude and phase response of LTI system by


%h(n)=(0.9)^n*u(n)
n=[0:1:500]*pi/500; %[0,pi]axis divided into 501 points
h=exp(j*n)./exp(j*n)-0.9*ones (1,501);
magh=abs(h);angh=angle(h);
subplot(2,1,1);plot(n/pi,magh);grid;
ylabel('|h|---->');
xlabel('Frequency in pi units');
title('Magnitude Response');
subplot(2,1,2);plot(n/pi,angh/pi);grid;
ylabel('phase in pi radians');
xlabel('Frequency in pi units');
title('Phase Response');

OUTPUT:
EXPERIMENT NO.9
AIM: To develop a program to design IIR filter with given specification using impulse
invariance method:-
f=input('enter cutoff frequency=');
fs=input('enter sampling frequency=');
[b,a]=butter(6,2*pi*f,'s');
[bz,az]=impinvar(b,a,fs);
freqz(bz,az,1024,fs)
title('magnitude and phase response created by 2203775')

OUTPUT:-
enter cutoff frequency= 5
enter sampling frequency= 15
EXPERIMENT NO.10
AIM: To develop a program to design IIR filter with given specification using bilinear
transformation method:-
f=input('enter cutoff frequency=');
fs=input('enter sampling frequency=');
[b,a]=butter(6,2*pi*f,'s');
[numd,dend]=bilinear(b,a,fs);
freqz(numd,dend,1024,fs)
title('magnitude and phase response created by 2203775')

OUTPUT:-
enter cutoff frequency= 15
enter sampling frequency= 45

You might also like