Are you sure?
This action might not be possible to undo. Are you sure you want to continue?

scribd.com/pakkorner
LAB MANUALS
LAB MANUAL
DIGITAL SIGNAL PROCESSING
DEPARTMENT :
ELECTRICAL ENGINEERING
SUBJECT :
LAB MANUALS
DEPARTMENT OF ELECTRICAL ENGINEERING
(A CONSTITUENT COLLEGE: RACHNA COLLEGE OF ENGINEERING &
TECHNOLOGY GUJRANWALA)
UNIVERSITY OF ENGINEERING & TECHNOLOGY LAHORE, PAKISTAN
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
LIST OF EXPERIMENTS
EXP# TITLE
01 Introduction to MATLAB and its basic commands
02 Introduction to different types of discrete time signals and their
plotting
03
Introduction to different operations on sequences
04
Generation of sinusoidal signals in MATLAB
05 Generation of complex exponential signals in MATLAB
06
Sampling of discrete time signals in MATLAB
07
Understanding of aliasing effect of discrete time signals in
MATLAB
08
Study of DiscreteTime Linear and NonLinear Systems in
MATLAB
09 Study of Convolution Theorem in MATLAB
10 Study of Correlation Theorem in MATLAB
11 Study of ZTransform in MATLAB
12 Study of frequency response in MATLAB
13 Study of DiscreteTime Fourier Transform in MATLAB
14 Study of Time Shifting Property of DiscreteTime Fourier
Transform in MATLAB
15 Study of Frequency Shifting Property of DiscreteTime Fourier
Transform in MATLAB
16 Study of Convolution Shifting Property of DiscreteTime Fourier
Transform in MATLAB
17 Study of Modulation Shifting Property of DiscreteTime Fourier
Transform in MATLAB
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 01
Introduction to MATLAB and its basic commands
MATLAB:
This is a very important tool used for making long complicated calculations and
plotting graphs of different functions depending upon our requirement. Using
MATLAB an mfile is created in which the basic operations are performed
which leads to simple short and simple computations of some very complicated
problems in no or very short time.
Some very important functions performed by MATLAB are given as follows:
Matrix computations
Vector Analysis
Differential Equations computations
Integration is possible
Computer language programming
Simulation
Graph Plotation
2D & 3D Plotting
Benefits:
Some Benefits of MATLAB are given as follows:
Simple to use
Fast computations are possible
Wide working range
Solution of matrix of any order
Desired operations are performed in matrices
Different Programming languages can be used
Simulation is possible
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Basic Commands:
Some basic MATLAB commands are given as follows:
Addition:
A+B
Subtraction:
AB
Multiplication:
A*B
Division:
A/B
Power:
A^B
Power Of each Element individually:
A.^B
Range Specification:
A:B
SquareRoot:
A=sqrt(B)
Where A & B are any arbitrary integers
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Basic Matrix Operations:
This is a demonstration of some aspects of the MATLAB language.
Creating a Vector:
Lets create a simple vector with 9 elements called a.
a = [1 2 3 4 6 4 3 4 5]
a =
1 2 3 4 6 4 3 4 5
Now let's add 2 to each element of our vector, a, and store the result in a new
vector.
Notice how MATLAB requires no special handling of vector or matrix math.
Adding an element to a Vector:
b = a + 2
b =
3 4 5 6 8 6 5 6 7
Plots and Graphs:
Creating graphs in MATLAB
is as easy as one command.
Let's plot the result of our
vector addition with grid
lines.
Plot (b)
grid on
MATLAB can make other
graph types as well, with axis
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
labels.
bar(b)
xlabel('Sample #')
ylabel('Pounds')
MATLAB can use symbols in
plots as well. Here is an
example using stars to mark the
points. MATLAB offers a
variety of other symbols and
line types.
plot(b,'*')
axis([0 10 0 10])
One area in which MATLAB
excels is matrix computation.
Creating a matrix:
Creating a matrix is as easy as making a vector, using semicolons (;) to separate
the rows of a matrix.
A = [1 2 0; 2 5 1; 4 10 1]
A =
1 2 0
2 5 1
4 10 1
Adding a new Row:
B(4,:)=[7 8 9]
ans=
1 2 0
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
2 5 1
4 10 1
7 8 9
Adding a new Column:
C(:,4)=[7 8 9]
ans=
1 2 0 7
2 5 1 8
4 10 1 9
Transpose:
We can easily find the transpose of the matrix A.
B = A'
B =
1 2 4
2 5 10
0 1 1
Matrix Multiplication:
Now let's multiply these two matrices together.
Note again that MATLAB doesn't require you to deal with matrices as a
collection of numbers. MATLAB knows when you are dealing with matrices
and adjusts your calculations accordingly.
C = A * B
C =
5 12 24
12 30 59
24 59 117
Matrix Multiplication by corresponding elements:
Instead of doing a matrix multiply, we can multiply the corresponding elements
of two matrices or vectors using the.* operator.
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
C = A .* B
C =
1 4 0
4 25 10
0 10 1
Inverse:
Let's find the inverse of a matrix ...
X = inv(A)
X =
5 2 2
2 1 1
0 2 1
... and then illustrate the fact that a matrix times its inverse is the identity
matrix.
I = inv(A) * A
I =
1 0 0
0 1 0
0 0 1
MATLAB has functions for nearly every type of common matrix calculation.
Eigen Values:
There are functions to obtain eigenvalues ...
eig(A)
ans =
3.7321
0.2679
1.0000
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Singular Value Decomposition:
The singular value decomposition
svd(A)
ans =
12.3171
0.5149
0.1577
Polynomial coefficients:
The "poly" function generates a vector containing the coefficients of the
characteristic polynomial.
The characteristic polynomial of a matrix A is
p = round(poly(A))
p =
1 5 5 1
We can easily find the roots of a polynomial using the roots function.
These are actually the eigenvalues of the original matrix.
roots(p)
ans =
3.7321
1.0000
0.2679
MATLAB has many applications beyond just matrix computation.
Vector Convolution:
To convolve two vectors ...
q = conv(p,p)
q =
1 10 35 52 35 10 1
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
... Or convolve again and plot the result.
r = conv(p,q)
plot(r);
r =
1 15 90 278 480 480 278 90 15 1
Matrix Manipulation:
We start by creating a magic square and assigning it to the variable A.
A = magic(3)
A =
8 1 6
3 5 7
4 9 2
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 02
Introduction to different types of discrete time signals and
their plotting
Introduction:
Discrete time signals are defined only at certain specific values of time. They
can be represented by x[n] where n is integer valued and represents discrete
instances in time. i.e:
X[n] = {., x[1], x[0] ,x[1] ,..}
Where the uparrow indicates the sample at n=0.
In MATLAB, we can represent a finiteduration sequence like above by a row
of vector of appropriate values. However such a vector does not have any
information about sample position n. therefore a correct representation of x[n]
would require two vectors, one each for x and n. for example a signal
X[n] = {2,1,1,0,1,4,3}
>>n=[3,2,1,0,1,2,3];
>>x=[2,1,1,0,1,4,3];
An arbitrary infinite duration signal cannot be represented by MATLAB
due to finite memory limitations.
Basic Signals:
Unit Sample Sequence
>>function[x, n] =impseq (n0, n1, n2)
% Generates x[n] =delta (nn0) ; n1<=n<=n2
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
% n1 is lower limit of required sequence;n2 is upper limit of required sequence
>>n=n1:n2;x=(nn0)==0;
>>stem(n,x);
>>title(Delayed Impulse);
>>xlabel(n);
>>ylabel(x[n]);
Practice:
Use above function to plot unit sample sequence that has a value at n=9 in a
range fro n=14 to n=2. Use zeros(1,N) command to generate above unit
sample sequence function
MATLAB CODE:
>> n0=9;
>> n1=14;
>> n2=2;
>> n=n1:n2;
>> x=(nn0)==0;
>> stem(n,x)
>> title('Delayed Impulse Sequence')
>> xlabel('n')
>> ylabel('x[n]')
PLOT:
>>funct
% Gene
% n1 is
>>n=n1
>>stem
>>title(
>>xlabe
tion[x, n] =
erates x[n]
lower lim
1:n2;x=(nn
(n,x);
Delayed S
el(n);
=stepseq (n
] =u (nn0)
mit of requ
n0)>=0;
Step Seque
Uni
n0, n1, n2
) ; n1<=n<
ired seque
ence);
it Step Seq
)
=n2
ence;n2 is u
quence
upper limiit of requi
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
red sequen
R
N
nce
>>ylabe
Practice
Use abo
shifted
step seq
MATLA
>> n0=
>> n1=
>> n2=1
>> n=n1
>> x=(n
>> stem
>> title(
>> xlab
>> ylab
PLOT:
el(x[n]);
e:
ove functio
at n=3. U
quence fun
AB CODE
3;
5;
15;
1:n2;
nn0)>=0;
m(n,x)
('Delayed
el('n')
el('x[n]')
on to plot
Use zeros(1
nction
:
Step Sequ
unit step s
1,N) and on
ence')
sequence h
nes(1,N) c
having ran
ommands
nge betwee
to genera
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
en 5 and
ate above u
R
N
15,
unit
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Realvalued Exponential Sequence
X[n] = a
n
In MATLAB, we can write
>>n=0:10; x=(0.9).^n
MATLAB RESULT OF ABOVE COMMAND:
x =
Columns 1 through 7
1.0000 0.9000 0.8100 0.7290 0.6561 0.5905 0.5314
Columns 8 through 11
0.4783 0.4305 0.3874 0.3487
Complexvalued Exponential Sequence
X[n] = e
(a+jw0)n
, for all n
MATLAB function exp is used to generate exponential sequences. For example
to generate
X[n]=exp[(2+3j)n],0<=n<=10, we can write:
>>n=0:10;x=exp((2+3j)*n)
MATLAB RESULT OF ABOVE COMMAND:
x =
1.0e+008 *
Columns 1 through 4
0.00 0.00+0.00i 0.000.00i 0.00+0.00i
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Columns 5 through 8
0.000.00i 0.0002+0.0001i 0.00110.0012i 0.0066+0.0101i
Columns 9 through 11
0.03770.0805i 0.1918+0.6280i 0.74844.7936i
Practice:
Generate a complex exponential given below in MATLAB and also plot the
output
X[n] = 2e
(0.5+(/6)j)n
MATLAB CODE:
>> n=0:10;
>> a=2;
>> b=exp((0.5+(pi/6)*j)*n);
>> x=a*b
>> plot(n,x)
MATLAB RESULT:
x =
Columns 1 through 4
2.000 1.050+0.606i 0.367+0.637i 0.000+0.446i
Columns 5 through 8
0.135+0.234i 0.142+0.082i 0.099+0.000i 0.0520.030i
Column
0.018
PLOT:
MATLA
Practice
Genera
output
>>x[n]=
MATLA
>> n=0:
>> a=3*
>> b=2*
ns 9 throug
0.032i 
AB functio
e:
te a sinuso
=3cos(0.1n
AB CODE
10;
cos((0.1*n
*sin(0.5*n*p
gh 11
0.0000.02
on sin or c
oidal signa
n+/3)+2
:
*pi)+pi/3);
pi);
22i 0.00
Sinu
X[n]=cos(w
os is used
al given be
2sin(0.5n
070.012i
usoidal Seq
w0n+), fo
to generat
elow in MA
)
quence:
or all n
te sinusoid
ATLAB an
dal sequen
nd also plo
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
nces.
t the
R
N
>> x=a+
>> plot(
PLOT:
Many p
those ab
charact
statistic
sequenc
generat
Above m
sequenc
+b;
(n,x)
practical se
bove. Thes
terized by
cal momen
ce whose e
tes a length
mentioned
ces.
equences c
se signals a
parameter
nts. In MA
elements a
h N Guass
d function
Ra
cannot be
are called
rs of associ
ATLAB ran
are uniform
ian random
ns can be tr
andom Sig
described
random o
iated prob
nd (1, N) ge
mly distrib
m sequenc
ransforme
gnals:
by mathem
r stochasti
bability den
enerates a
buted betw
ce with me
ed to gener
matical ex
ic signals a
nsity func
length N
ween [0, 1]
ean 0 and
rate other
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
xpressions
and are
tions or th
random
].randn (1
variance 1
random
R
N
like
heir
, N)
1.
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXAMPLE:
>> rand(1,5)
RESULT:
ans =
0.0975 0.2785 0.5469 0.9575 0.9649
Periodic Signals:
Nncopy can be used to produce a vector with repeating sequence. If we want a
vector x in below example to repeat for three times, we can use,
>>x=[1 2 3];
>>y=nncopy(x,1,3);
1 2 3 1 2 3 1 2 3
Practice:
Write MATLAB code for generating a periodic sequence using only ones
command.
CODE:
>> x=ones(1,2);
>> y=nncopy(x,3,3)
RESULT:
y = 1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 03
Introduction to different operations on sequences
Operations on sequences:
Signal addition:
In MATLAB, two sequences are added sample by sample using arithmetic
operator +. However if lengths of sequences are different or if sample positions
are different for equallength sequences, then we can not directly use +
operator. In this case, we have to augment the sequences so that they have same
position vector n(and hence the same length). Following is the code for
sequence addition keeping in view above mentioned facts.
Function[y,n]=sigadd(x1,n1,x2,n2)
%implemnts y[n]=x1[n]+x2[n]
%y=sum sequence over n which includes n1 and n2
%x1=first sequence over n1
%x2=second sequence over n2(n2 can be different from n1)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeroes(1,length(n));y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1+y2;
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Practice:
x1[n]=[3,11,7,0,1,4,2] and x2[n]=[2,3,0,5,2,11]
Use above function to add two signals.
MATLAB CODE:
x1=[3 11 7 0 1 4 2];
x2=[2 3 0 5 2 11];
n1=4;%initial element number of x1
n2=3;%initial element number of x2
if n2<n1
x2=[zeros(1,length(n1n2)) x2];
x1=x1;
if length(x1)>length(x2)
x2=[x2 zeros(1,length(x1)length(x2))]
x1=x1
x=x1+x2
elseif length(x1)<length(x2)
x1=[x1 zeros(1,length(x2)length(x1))]
x2=x2
x=x1+x2;
elseif length(x1)==length(x2)
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
x=x1+x2;
end
elseif n2>n1
x1=[zeros(1,length(n2n1)) x1];
x2=x2;
if length(x1)>length(x2)
x2=[x2 zeros(1,length(x1)length(x2))]
x1=x1
x=x1+x2
elseif length(x1)<length(x2)
x1=[x1 zeros(1,length(x2)length(x1))]
x2=x2
x=x1+x2;
elseif length(x1)==length(x2)
x=x1+x2;
end
elseif n2==n1
if length(x1)>length(x2)
x2=[x2 zeros(1,length(x1)length(x2))]
x1=x1
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
x=x1+x2
elseif length(x1)<length(x2)
x1=[x1 zeros(1,length(x2)length(x1))]
x2=x2
x=x1+x2;
elseif length(x1)==length(x2)
x=x1+x2;
end
end
MATLAB RESULTS:
x2 = 2 3 0 5 2 11 0 0
x1 = 0 3 11 7 0 1 4 2
x = 2 6 11 2 2 10 4 2
Signal multiplication:
In MATLAB, two signals are multiplied sample by sample using array operator
*. Similar instructions regarding position vector imply for multiplication as for
addition.
Practice:
Write a MATLAB function sigmult to multiply two signals x1[n] and x2[n],
where x1[n] and x2[n] may have different durations. Call this function to
multiply any two signals.
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
MATLAB RESULTS:
x2 = 2 3 0 5 2 11 0 0
x1 = 0 3 11 7 0 1 4 2
x = 0 9 0 35 0 11 0 0
Signal shifting:
In this operation each sample of x[n] is shifted by an amount k to obtain a
shifted sequence y[n].
y[n]=x[nk]
This operation has no effect on vector x but vector n is changed by adding k to
each element.
Function[y,n]=sigshift(x,m,n0)
%implements y[n]=x[nn0]
n=m+n0;
y=x;
Signal Folding:
In this operation each sample of x[n] is flipped around n=0 to obtaib a folded
sequence y[n].
y[n]=x[n]
In MATLAB, this function is implemented by flipr(x) function for sample
values and by flipr(n) function for sample positions.
Function[y,n]=sigfold(x,n)
%implements y[n]=x[n]
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Y=flipr(x);
n=flipr(n)
Sample Summation and Sample Product:
It adds all sample values of x[n] between n1 and n2. It is implemented by
sum(x(n1:n2)).
Sample multiplication multiplies all sample values of x[n] between n1 and n2. It
is implemented by prod(x(n1:n2)).
MATLAB CODE FOR SUMMATION:
x=[1 2 3 4 5 6];
n1=x(1,3);
n2=x(1,5);
sum(x(n1:n2))
RESULT:
ans =12
MATLAB CODE FOR PRODUCT:
x=[1 2 3 4 5 6];
n1=x(1,3);
n2=x(1,5);
prod(x(n1:n2))
RESULT:
ans =60
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
Signal Energy:
Energy of a finite duration sequence x[n] can be computed in MATLAB using
>>Ex=sum(x.*conj(x));
or
>>Ex=sum(abs(x).^2);
MATLAB CODE:
x=[1 2 3];
Ex=sum(abs(x).^2)
RESULT:
Ex =14
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 04
Generation of sinusoidal signals in MATLAB
THEORY:
In this lab, discretetime sinusoidal signal has been introduced. A
discrete sinusoidal signal can be either sine or cosine time discrete signal and it
can be expressed by:
X(n)=Asin(wn+), <n<
Where w=2*pi*f
Therefore
x(n)=Asin(2*pi*fn+ ), <n<
Similarly, discretetime sinusoidal signal for a cosine function can be expressed
as
X(n)=Acos(2*pi*fn+ ), <n<
Where
n=integer variable called the sampler no.
A=Amplitude of the sinusoid.
w=frequency in radian per sample
=phase in radians
As the maximum value of the functions SINE & COSINE is unity, the A acts as
a scaling factor giving maximum and minimum values of ±A.
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
OBJECTIVES:
To learn the generation of discrete time sinusoidal signals
To perform the elementary operations of shifting(advanced and delayed)
To learn the techniques of doing scaling(time and amplitude)
To learn the application of some basic commands of MATLAB for simple
digital signal processing problems
MATLAB CODE:
n=0:40;
f=0.1;
phase=0;
A=1.5;
arg=2*pi*f*nphase;
x=A*cos(arg);
clf; %clear and graph
stem(n,x);
axis([0 40 2 2]);
grid;
title('Sinusoidal Sequence');
xlabel('Time index n');
ylabel('Amplitude');
axis;
RESULT
ANSWE
(1)Wha
ANS: n
(2)Wha
ANS: f=
(3)Wha
ANS: p
(4)Wh
ANS: A
(5)Wh
ANS: f=
T:
ERS TO T
at is the pe
n=10
at comman
=0.1
at paramet
phase
at parame
A
at is the F
=0.1 Hz
THE QUES
eriod of th
nd line con
ter control
ter contro
REQUENC
STIONS:
e Sequenc
ntrols the
ls the PHA
ols the AM
CY of this
ce?
FREQUEN
ASE of this
MPLITUDE
Sequence
NCY in the
s sequence
E of the seq
e?
e program
e?
quence?
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
m?
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 05
Generation of complex exponential signals in MATLAB
THEORY:
In this lab, discretetime complex exponential signal has been introduced.
By using complex numbers the exponential and sinusoidal signals can be
written as special cases of a more general signal, the complex exponential.
Consider the case:
X(n)=Ae
an
If a is real, it is a simple discretetime exponential signal. Taking, a=jw the
signal becomes:
X(n)=Ae
jwn
X(n)=Acos(wn)+jsin(wn)
Hence, the discretetime exponential signal can be generalized to represent a
sinusoidal of arbitrary phase by writing:
X(n)=Ae
j(n
+)
=Ae
jn
*e
j
OBJECTIVES:
To learn the generation of discrete time complex exponential signals
To learn the effect of changing different parameters of the signal
To learn the application of some basic commands of MATLAB for simple
digital signal processing problems
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
MATLAB CODE:
%Generation of a complex EXPONENTIAL SEQUENCE
clf;
c=(1/12)+(pi/6)*i;
k=2;
n=0:40;
x=k*exp(c*n);
subplot(2,1,1);
stem(n,real(x));
xlabel('Time index n');
ylabel('Amplitude');
title('Real part');
subplot(2,1,2);
stem(n,imag(x));
xlabel('Time index n');
ylabel('Amplitude');
title('imaginary part');
Result:
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 06
Sampling of discrete time signals in MATLAB
MATLAB CODE:
%Illustration of sampling process
%in the time domain
clf;
t=0:0.0005:1;
f=13;
xa=cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);
grid;
xlabel('Time,msec');
ylabel('Amplitude');
title('Continuous time signalx_{a}(t)');
axis([0 1 1.2 1.2])
subplot(2,1,2);
T=0.1;
n=0:T:1;
xs=cos(2*pi*f*n);
k=0:length(n)1;
stem(k,xs);
grid;
xlabel('Time index n');
ylabel('Amplitude');
title('Discrete time signalx[n]');
axis([0 (length(n)1) 1.2 1.2
MATLAAB RESULLT:
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 07
Understanding of aliasing effect of discrete time signals in
MATLAB
THEORY:
Aliasing is the phenomenon that results in a loss of information when a signal is
reconstructed from its sampled signal.
In Principle, the analogue can be reconstructed from the samples, provided that
the sampling rate is sufficiently high to avoid the problem called Aliasing.
MATLAB CODE:
%Illustration of Aliasing Effect in the TimeDomain
clf;
t=0:0.0005:1;
f=13;
xa=cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);
grid
Xlabel('Time,msec');
Ylabel('Amplitude');
title('Continous=time signal x_{a}(t)');
axis([0 1 1.2 1.2])
subplot
T=0.1;
F=13;
n=0:T:1
xs=cos(2
t=linspa
ya=sinc
plot(n,x
grid;
xlabel('
ylabel('
title('Re
axis([0
1.2 1.2]
RESULT
t(2,1,2);
1;
2*pi*f*n);
ace(0.5,5,
c((1/T)*t(:,o
xs,'0',t,ya);
Time,mse
Amplitud
econstruct
1 
);
T:
500);
ones(size(n
;
c');
e');
ted contin
n)))(1/T)*
uoustime
*n(:,ones(s
e signal y_
ize(t))))*xs
{a}(t)');
s;
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 08
Study of DiscreteTime Linear and NonLinear Systems in
MATLAB
THEORY:
In this experiment following two types of DiscreteTime systems have been
introduced.
Linear DiscreteTime system:
A system which satisfies SuperPosition Principle is a linear system.
Hence, a relaxed T system is linear if and only if
T[a1x1(n)+ x2(n)=Ta1[x1(n)]+Ta2[x2(n)]
For any arbitrary input sequences x1(n) and x2(n), and arbitrary constants a1 and
a2
NonLinear DiscreteTime system:
A system which doesnt satisfy SuperPosition Principle, given above is non
linear system.
In this lab given below, we investigate LINEARITY property of a causal system
of the type given below;
_ Jk
N
k=0
y{n  k] = _ Pk
M
k=0
x(nk)
MATLAB CODE:
>> %Generate the input sequences
>> a=2;
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
>> b=3;
>> clf;
>> n=0:40;
>> X1=cos(2*pi*0.1*n);
>> X2=cos(2*pi*0.1*n);
>> X=a*X1+a*X2;
>> num=[2.2403 2.4908 2.2403];
>> den=[1 0.4 0.75];
>> ic=[0 0];
>> Y1=filter(num,den,X1,ic); %Compute the output Y1[n]
>> Y2=filter(num,den,X2,ic); %Compute the output Y2[n]
>> Y=filter(num,den,X,ic); %Compute the output Y[n]
>> Yt=a*Y1+b*Y2;
>> d=YYt;%Compute the difference output d[n]
>> %Plot the output and difference signal
>> subplot(3,1,1)
>> stem(n,Y);
>> ylabel('Amplitude');
>> title('Output Due to Weighted Input:a\cdot x_{1}[n]+b\cdot x_{2}[n]');
>> subplot(3,1,2)
>> stem
>> ylab
>> title(
>> subp
>> stem
>> xlab
>> ylab
>> title(
RESULT
m(n,Yt);
el('Amplit
('Output D
plot(3,1,3)
m(n,d);
el('Time in
el('Amplit
('Differenc
T:
tude');
Due to We
ndex n');
tude');
ce Signal')
eighted Inp
;
put:a\cdot y_{1}[n]++b\cdot y_{
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
{2}[n]');
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 09
Study of Convolution Theorem in MATLAB
THEORY:
The convolution of the equation
Y[n]=h[n]*x[n]
is implemented in MATLAB by the command copy, provided the two
sequences to be convolved are of finite length. For example, the output
sequence of an FIR system can be computed by convolving its impulse response
with a given finitelength input sequence.
The following MATLAB program illustrates this approach;
MATLAB CODE:
>> clf;
>> h=[3 2 1 2 1 0 4 0 3];
>> x=[1 2 3 4 3 2 0 0 1];
>> y=conv(h,x);
>> n=0:4;
>> plot(1,1);
>> stem(n:y);
>> xlabel('Time Index');
>> ylabel('Amplitude');
>> title('Output Obtained by Convolution');
>> grid;
MATLA
;
AB RESULLT:
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 10
Study of Correlation Theorem in MATLAB
THEORY:
Correlation is the process that is necessary to be able to quantify the degree of
interdependence of one process upon another or to establish the similarity
between one set of data and another.
Hence, the correlation between the processes can be sought and can be defined
mathematical and can be quantified.
Correlation is also an integral part of the process of convolution. The
convolution process is essential the correlation of two data sequences in which
one of the sequences have been reversed.
This means that the same algorithms may be used to compute correlations and
convolutions simply by reversing one of the sequences.
The two types of correlations discussed in this lab are;
Cross Correlation
Auto Correlation
MATLAB CODE:
>> %Output Obtained by Cross Correlation
>> clf;
>> x1=[4 2 1 3 2 6 5 4 5];%first sequence
>> x2=[4 1 3 7 4 2 8 2 1];%second sequence
>> y=xcorr(x1,x2);
>> n=0:
>> plot(
>> stem
>> xlab
>> ylab
>> title(
>> grid;
MATLA
16;
(1,1);
m(n:y);
el('Time In
el('Amplit
('Output O
;
AB RESUL
ndex');
tude');
Obtained b
LT:
by Correlation');
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 11
Study of ZTransform in MATLAB
THEORY:
ZTransform technique is an important tool in the analysis of characterization
of discrete time signals and LTI systems; ZTransform gives the response of
various signals by its pole zero locations.
ZTransform is an important tool in DSP that gives the solution of difference
equation in one go.
The ZTransform of a discrete time system x (n) is defined as power series;
X(z)=_ x(n)z^(n)
n=I
And the inverse ZTransform is denoted by;
X(n)=Z
1
[X(n)]
Since, ZTransform is the infinite power series; it exists only for the region for
which this series converges (region of convergence). Inverse ZTransform is the
method for inverting the ZTransform of a signal so as to obtain the time
domain representation of signal.
The features of ZTransform which are explained are as fellows;
ZTransform of a Discrete time function
EXAMPLE:
X(z) =
1  1.618uz
1
+ z^(2)
1  1.S161z^(1) + u.8781z^(2)
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
MATLAB CODE:
>> b=[1 1.6 180 1];
>> a=[1 1.5 161 0.878];
>> A=roots(a)
>> B=roots(b)
>> zplane(b,a)
RESULTS:
A =
0.7527 +12.6666i
0.7527 12.6666i
0.0055
B =
0.8028 +13.3927i
0.8028 13.3927i
0.0056
Pole=Ze
ZTran
Or
Let the
MATLA
>> syms
>>a=ztr
MATLA
ans=
ero Diagra
ZTR
sform is de
difference
AB CODE
s z n
rans(1/4^n
AB RESUL
am:
RANSFOR
efined as,
e equation
:
n)
LT:
RMOF A D
X(z)=
X(z
n be,
DISCRETE
z)=Z[x(n)]
E TIME FUUNCTION
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
N:
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
4*z/4*z1
INVERSE ZTRANSFORM:
The inverse ZTransform is denoted by,
X(n)=Z
1
[X(z)]
Let the Zdomain is:
X(z) =
2z
2zs  1
MATLAB CODE:
>> syms z n
>>iztrans(2*z/(2*z
1
))
MATLAB RESULT:
ans=
(1/2)^n
POLE ZERO DIAGRAM FOR A FUNCTION IN ZDOMAIN
zplane command computes and displays the polezero diagram of zfunction.
The command is
>>zplane(b,a)
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 12
Study of frequency response in MATLAB
FREQUENCY RESPONSE ESTIMATION
The freqz function computes and displays the frequency response of given
Z=Transform of the function.
The command is
>>freqz(b,a,npt,Fs)
Where, Fs is the Sampling Frequency, npt is the no. of frequency points
between and Fs/2.
EXAMPLE:
X(z) =
1  1.618uz
1
+ z^(2)
1  1.S161z^(1) + u.8781z^(2)
MATLAB CODE:
>> b=[1 1.6 180 1];
>> a=[1 1.5 161 0.878];
>> freqz(b,a)
MATLAAB RESULLT:
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 13
Study of DiscreteTime Fourier Transform in MATLAB
THEORY:
The discretetime Fourier transform (DTFT) X(e
jwt
)of a sequence Z(n)is a
continuous function of wt. Since the data in MATLAB is in vector form, X(e
jwt
)
can only be evaluated at a prescribed set of discrete frequencies. Moreover, only
a class of DTFT that is expressed as a rational function in
ejwt
in the form,
X(c
]wt
) =
Po + P1(c
]wt
) +·+ Pn(c
]wM
)
uo + u1(c
]wt
) +·+un(c
]wM
)
can be evaluated. In the following lab work you will learn how to evaluate
DTFT and study its certain properties using MATLAB.
DTFT Computation
The DTFT X(e
jwt
) of a sequence x(n) of the form,
X(c
]wt
) =
Po + P1(c
]wt
) +·+ Pn(c
]wM
)
uo + u1(c
]wt
) +·+un(c
]wM
)
Can be computed easily at a prescribed set of L discrete frequency points w=wf
using the MATLAB function freqz. Since, X(e
jwt
) is a continuous function of w,
it is necessary to make L as large as possible so that the plot generated using the
command provides a reasonable replica of the actual plot of DTFT. In MATLAB
freqz computes the L point DFT of the sequences Po +P1(c
]wt
) + ·+
Pn(c
]wM
) and uo + u1(c
]wt
) + ·+un(c
]wM
) and then forms the ratio to
arrive at X(e
jwt
).l=1,1,,L. For faster computations L should be chosen as a
power of 2, such as 256 or 512.
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
MATLAB CODE:
%Evaluation of the DTFT
clf;
%Compute the frequency samples of DTFT
w=4*pi : 8*pi/511 : 4*pi;
num=[2 1];
den= [1 0.6];
h=freqz (num, den, w);
%plot the DTFT
Subplot(2,1,1)
plot(w/pi,real(h));
grid
title('Real part of H(e^{j\omega})')
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,imag(h));
grid
title('Real part of H(e^{j\omega})')
xlabel('\omega/\pi');
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
ylabel('Amplitude');
pause
subplot(2,1,2)
plot(w/pi,abs(h));
grid
title('Magnitude Spectrum H(e^{j\omega})')
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,abs(h));
grid
title('Phase Spectrum arg [H(e^{j\omega})]')
xlabel('\omega/\pi');
ylabel('Phase, radians');
MATLAAB RESULLTS:
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 14
Study of Time Shifting Property of DiscreteTime Fourier
Transform in MATLAB
THEORY:
Most of the properties of DTFT can be verified using MATLAB. In the
following we shall verify the different properties of DTFT using MATLAB.
Since all data in MATLAB have infinite length vectors, the sequences being
used to verify the properties are of finite length.
TIMESHIFTING:
%Timeshifting Properties of DTFT
clf;
w=pi:2*pi/255:pi ;
w0=0.4*pi;
D=10;
num=[1 2 3 4 5 6 7 8 9];
h1=freqz(num,1,w);
h2=freqz([zeros(1,D) num],1,w);
subplot(2,2,1);
plot(w/pi,abs(h1));
grid
title('Magnitude Spectrum of orig Seq')
subplot
plot(w/
grid;
title('M
subplot
plot(w/
grid;
title('Ph
subplot
plot(w/
grid;
title('Ph
MATLA
t(2,2,2)
/pi,abs(h2)
Magnitude S
t(2,2,3)
/pi,angle(h
hase Spect
t(2,2,4)
/pi,angle(h
hase Spect
AB RESUL
);
Spectrum
h1));
trum of Or
h2));
trum of Tim
LTS:
of TimeS
rig Seq')
meShifted
Shifted Seq
d Seq')
q')
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 15
Study of Frequency Shifting Property of DiscreteTime
Fourier Transform in MATLAB
FRQUENCYSHIFTING PROPERTY:
%FrequencyShifting Properties of DTFT
clf;
w=pi : 2*pi/255 : pi ;
w0=0.4*pi;
num1=[1 3 5 7 9 11 13 15 17];
L=length(num1);;
h1=freqz(num1, 1,w);
n=0:L1;
num2=exp(w0*i*n).*num1;
h2=freqz(num2, 1, w);
subplot(2,2,1);
plot(w/pi,abs(h1));
grid
title('Magnitude Spectrum of orig Seq')
subplot(2,2,2)
plot(w/pi,abs(h2));
grid;
title('M
subplot
plot(w/
grid;
title('Ph
subplot
plot(w/
grid;
title('Ph
MATLA
Magnitude S
t(2,2,3)
/pi,angle(h
hase Spect
t(2,2,4)
/pi,angle(h
hase Spect
AB RESUL
Spectrum
h1));
trum of Or
h2));
trum of Fre
LTS:
of FreqSh
rig Seq')
eqShifted
hifted Seq'
d Seq')
')
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 16
Study of Convolution Shifting Property of DiscreteTime
Fourier Transform in MATLAB
CONVOLUTION PROPERTY:
%Convolution Property of DTFT
clf;
w=pi : 2*pi/255 : pi ;
x1=[1 3 5 7 9 11 13 15 17];
x2=[1 2 3 2 1];
y=conv(x1,x2);
h1=freqz(x1, 1, w);
h2=freqz(x2,1,w);
hp=h1.*h2;
h3=freqz(y,1,w);
subplot(2,2,1)
plot(w/pi,abs(hp));
grid
title('Product of Magnatude Spectra')
subplot(2,2,2)
plot(w/pi,abs(h3));
grid
title('M
subplot
plot(w/
grid
title('Su
subplot
plot(w/
grid
title('Ph
MATLA
Magnatude
t(2,2,3)
/pi,angle(h
um of Phas
t(2,2,4)
/pi,angle(h
hase Spect
AB RESUL
Spectra of
hp));
se Spectra
h3));
tra of Conv
LTS:
f Convolve
')
volved Seq
ed Sequen
quence')
ce')
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
EXPERIMENT NO: 17
Study of Modulation Shifting Property of DiscreteTime
Fourier Transform in MATLAB
MODULATION PROPERTY:
%Modulation Property of DTFT
clf;
w=pi:2*pi/255:pi ;
x1=[1 3 5 7 9 11 13 15 17];
x2=[1 1 1 1 1 1 1 1 1];
y=x1.*x2;
h1=freqz(x1,1,w);
h2=freqz(x2,1,w);
h3=freqz(y,1,w);
subplot(3,1,1)
plot(w/pi,abs(h1));
grid
title('Magnatude Spectrum of first Seq')
subplot(3,1,2)
plot(w/pi,abs(h2));
grid
title('M
subplot
plot(w/
grid
title('M
MATLA
Magnatude
t(3,1,3)
/pi,angle(h
Magnitude S
AB RESUL
Spectrum
h3));
Spectrum
LTS:
of Second
of Produc
d Seq')
ct Sequence')
 Downloaded From 
scribd.com/pakkorner
LAB MANUALS
R
N
This action might not be possible to undo. Are you sure you want to continue?