Bappydsp Lab Report
Bappydsp Lab Report
Bappydsp Lab Report
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}
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
𝑦(𝑛0 ) = ∑ 𝑥(𝑘)ℎ(𝑛0 − 𝑘)
𝑘=−∞
>> 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()
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
𝑿(ω) = ∑ 𝒙(𝒏)𝒆−𝒋𝝎𝒏
−∞
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𝑗𝜋 )𝑛
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:
𝑿(𝒛) = ∑ 𝒙(𝒏)𝒛−𝒏
𝒏=−∞
• 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:
PRECAUTION:
10 | P a g e