Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

INDEX

NO NAME OF EXPERIMENT PAGE

1 SKETCH DISCRETE TIME SIGNAL IN MATLAB 2-4

2 CONVOLUTION OF TWO DT SIGNAL

3 DISCRETE FOURIER TRANSFORM

1|Page
NAME OF THE EXPERIMENT: SKETCH DISCRETE TIME SIGNAL IN MATLAB

OBJECTIVE: To study graphical representation of DT signal and perform shifting, scaling, folding
and addition of it.
THORY: A discrete-time signal is a sequence of values that correspond to particular instants in
time. The time instants at which the signal is defined are the signal's sample times, and the
associated signal values are the signal's samples.

Fig: DT signal
A DT signal can be represented in various way.

• Functionality
• Tabularly
• Sequentially
• Graphically

For example: Let x(n) be a DT signal. Sequentially x(n) can be written as x(n)={ -2,3,0,-1,2,3,1}

Graphically the signal can be shown as

Fig: Graphical Representation of x(n)


Required Equipment:
1. Personal Computer
2. Matlab Program

2|Page
PROBLEM: Let x(n) = {2, 2, 3 ,4, 5, 6, 7, 4, 2, 4, 3, 2, 2}. Determine and plot the following
sequence.

𝒙𝟏 (𝒏) = 𝟓𝒙(𝒏 − 𝟒) − 𝟐𝒙(𝒏 + 𝟑)

CODE:

clear all
close all
x=[2 2 3 4 5 6 7 4 2 4 3 2 2];
n=-2:10;
n1=n+4; %x(n-4)
x1=x*5; %5*x(n-4)
n2=n-3;%-x(n+3)
x2=x2*2; %-2*x(n+3)
%x1(n)=2x(n ? 5) ? 3x(n + 4)
n3=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n3));
y2=zeros(1,length(n3));
y1((n3>=min(n1))&(n3<=max(n1)))=x1();
y2((n3>=min(n2))&(n3<=max(n2)))=x2();
x=y1-y2;
stem(n3,x)
title('DT signal')
xlabel('n')
ylabel('x(n)')

3|Page
OUTPUT:

PRECAUTION:
1. For signal having different limit, we must assign them to same limit
2. Left and right shift are done using opposite signs.
3. Limit for each signal elements were set carefully.

4|Page
NAME OF THE EXPERIMENT: CONVOLUTION OF TWO DT SIGNAL

OBJECTIVE: To study convolution of two DT signals.


THEORY : If x(n) and h(n) is two distinct DT signal and y(n0) is the convolution between them,
then we can write

𝑦(𝑛0 ) = ∑ 𝑥(𝑘)ℎ(𝑛0 − 𝑘)
𝑘=−∞

So we can see that convolution can be done in 4 step:


➢ Folding. Fold h(k) about k = 0 to obtain h(-k).
➢ Shifting. Shift h( -k) by no to the right (left) if no is positive (negative), to obtain h(no - k).
➢ Multiplication. Multiply x(k) by h(no - k) to obtain the product sequence vno(k) ==
x(k)h(no - k).
➢ Summation. Sum all the values of the product sequence vno(k) to obtain the value of
the output at time n = no.
Matlab has a library function conv() which can be utilized to determine convolution of two DT
signal. The function takes two perimeters and outputs convolution of them.
Typical command:
>> x = [3, 11, 7, 0, -1, 4, 2]; h = [2, 3, 0, -5, 2, 1];

>> y = conv(x, h)

y = 6 31 4 7 6 -51 -5 41 18 -22 -3 8 2

But this function has a major problem, that is it do not care where the center is or was and also
the convoluted signal do not have any center indication. To Solve this problem, a function can
be created.

PROBLEM: For
X(n)={2,1,3,4,5,3,2,1} and h(n)={1,0,1,0,1,0,1} find convolution of x(n) and h(n).

5|Page
Code For Function conv_m()

function [y,ny] = conv_m(x,nx,h,nh)


nyb = nx(1)+nh(1); nye = nx(length(x)) + nh(length(h));
ny = [nyb:nye]; y = conv(x,h);

CODE:

close all;
clear all;
x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3];
h = [2, 3, 0, -5, 2, 1]; ny = [-1:4];
[y,ny] = conv_m(x,nx,h,ny)
disp(y)
disp(ny)
stem(ny,y)
title('Convolution of x(n) and h(n)')

OUTPUT:

RESULT:
Y(n)={ 2 1 5 5 10 8 12 9 10 8 7 4 2 1}

PRECAUTION
➢ Function was called using proper arguments.
➢ Limit for each sequence were selected carefully.
➢ The file containing the function must be in the same directory as the code where the
solve were written.

6|Page
NAME OF THE EXPERIMENT: DISCRETE FOURIER TRANSFORM

OBJECTIVE: To study discrete Fourier Transform.


THEORY: The main drawback of Fourier series is, it is only applicable to periodic signals. There
are some naturally produced signals such as nonperiodic or aperiodic, which we cannot
represent using Fourier series. To overcome this shortcoming, Fourier developed a
mathematical model to transform signals between time (or spatial) domain to frequency
domain & vice versa, which is called 'Fourier transform'.
.

Fig: Fourier Transform

The discrete-time Fourier transform (DTFT) or the Fourier transform of a discrete–time


sequence x[n] is a representation of the sequence in terms of the complex exponential
sequence ejwn
The DTFT sequence x(n) is given by

𝑿(ω) = ∑ 𝒙(𝒏)𝒆−𝒋𝝎𝒏
−∞

The Magnitude and Angle can be easily determined using matlab builtin functions abs() and
angle().
REQUIRED COMPONENTS:

• PERSONAL COMPUTER
• MATLAB program

7|Page
Problem: For

𝑥(𝑛) = (𝑒 2𝑗𝜋 )𝑛

Determin X(ω) and find angle and phase for 0<n<5


CODE:

clear all;
close all;
a=10;
n = 0:5; x =(exp(j*2*pi)).^n;
k = -200:200; w = (pi/100)*k;
X=x*(exp(-j*pi/100)) .^ (n'*k);
magX = abs(X); angX =angle(X);
subplot(2,1,1); plot(w/pi,magX);grid
xlabel('Frequency in units of pi'); ylabel('|x|')
title('Magnitude Part')
subplot(2,1,2); plot(w/pi,angX/pi);grid
xlabel('frequency in units of pi'); ylabel('radians/pi')
title('Angle Part')

OUTPUT:

8|Page
PRECAUTIONS:

• While using the ^ operator, dot(.) was placed before it


• Smaller range of k produces cleaner graph
• subplot() function were given appropriate arguments.

NAME OF THE EXPERIMENT: Z TRANSFORMATION OF A DT SIGNAL.

OBJECTIVE: To study Z transformation of a DT signal.


Theory: In mathematics and signal processing, the Z-transform converts a discrete-time signal,
which is a sequence of real or complex numbers, into a complex frequency-domain
representation. Z transforms are particularly useful to analyze the signal discretized in time.
Hence, we are given a sequence of numbers in the time domain. z transform takes these
sequences to the frequency domain (or the z domain), where we can check for their stability,
frequency response, etc. Hence, taking z transforms is analogous to taking Laplace transforms
for continuous signals.
The z-transform of a sequence x(n) is given by

𝑿(𝒛) = ∑ 𝒙(𝒏)𝒛−𝒏
𝒏=−∞

where z is a complex variable


REQUIRED COMPONENTS:

• PERSONAL COMPUTER
• MATLAB program
Problem: For the given sequence, determine z-transform
X1(n) = {1, 2, 5, 7, 0, 1}

9|Page
CODE:

clc
clear all
close all
x=[1 2 5 7 0 1]; %input signal here
l=length(x);
X=0;
z=sym('z');
for i=0:l-1

X=X+x(i+1)*z^(-i);

end

disp(X)

OUTPUT:

RESULT: z-transform of x(n) is


2 5 7 1
𝑋(𝑧) = + 2+ 3+ 5+1
𝑧 𝑧 𝑧 𝑧

PRECAUTION:

• The input sequence were given carefully


• The variable z was declared as symbolic variable. The code won’t work unless we
declare z as symbolic variable.
• As the loop contains iterative summation of X, it was assigned 0 outside the loop.

10 | P a g e

You might also like