0% found this document useful (0 votes)
92 views8 pages

Lab Report 3 DSP

1) The lab report discusses basic signal processing operations in MATLAB like shifting, folding, and arithmetic operations on discrete-time sequences. 2) The student completed tasks to shift signals by a delay, fold signals, add two signals of different lengths, and determine various sequences through shifting, scaling, addition, and multiplication. 3) The critical analysis concludes that basic signal operations like shifting, reversal, scaling, addition, and multiplication were studied in the lab.

Uploaded by

Khansa Maryam
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)
92 views8 pages

Lab Report 3 DSP

1) The lab report discusses basic signal processing operations in MATLAB like shifting, folding, and arithmetic operations on discrete-time sequences. 2) The student completed tasks to shift signals by a delay, fold signals, add two signals of different lengths, and determine various sequences through shifting, scaling, addition, and multiplication. 3) The critical analysis concludes that basic signal operations like shifting, reversal, scaling, addition, and multiplication were studied in the lab.

Uploaded by

Khansa Maryam
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/ 8

LAB REPORT # 02

NAME: KHANSA MARYAM.

ROLL NO.: FA20-BEE-232.

SUBMITTED TO: SIR MOBEEN SABIR.

SUBJECT: DIGITAL SIGNAL PROCESSING.

DATED: 04-03-2023.

1
Lab # 03:
Basic Operations on Discrete-Time Sequences
Objective:
By the end of this lab students will be able to perform signal shifting and folding operations in
MATLAB, in addition students will be able to perform arithmetic operations like adding,
subtracting or multiplying signals of different lengths.

Lab Tasks:
Task-1:
Take an exponential signal and perform scaling operation with a negative integer as given
in In-Lab Work section and plot the result.

CODE:
n=[0:6];
x=exp(n)
subplot(2,1,1)
stem(n,x)
y=exp(n)*(-3)
subplot(2,1,2)
stem(n,y)

Task-2:
Write a Matlab function “sigshift” for producing a delay of k in a given sequence ‗x[n]‘
defined by arrays x and n by using the pseudo code given in In-Lab Work section. Your
function should yield y[n] = x[n-k]. Function [y,n]=sigshift(x,n,k)

2
CODE:
function [y,n]=sshift(x,k)
n=0:5;
k=4;
x=[3,4,6,9,4,0];
subplot(2,1,1)
stem(n,x)
if k<0
n=0+k:5+k;
y=x;
else k>0
n=0-k:5-k;
y=x;
end
subplot(2,1,2)
stem(n,y)
end

Task-3:
Write a Matlab function sigfold for folding a given sequence ‗x[n]‘ defined by arrays x and
n by using the pseudo code given in In-Lab Work section.
Function [y,n]=sigfold(x,n)

CODE:
function [y,n]=sigfold(x,n)
n=0:4;
n1=-n;
x=[1,2,4,5,2]
subplot(2,1,1)
stem(n,x)
subplot(2,1,2)
stem(n1,x)

3
Task-4:
Write a Matlab function sigadd for adding two sequences x1[n] and x2[n] by using the
pseudo code given in In-Lab Work section.
Function [y,n]=sigadd(x1,n1,x2,n2)

CODE:
function [ y,x ] = SigAdd( x1,n1,x2,n2 )
x1=[1,2,3,4]
x2=[2,3,4,5,7]
n1=0:3
n2=1:4
if(x1(1)<x2(1))
a = n2(1)<n1(1);
x2 = [zeros(1,a),x2];
n2(1)=n1(1)
elseif(n2(1)<x1(1))
b = n1(1)-n2(1);
x1 = [zeros(1,b),x1];
x1(1)=n2(1);
end
if(n1(end)>n2(end))
c = n1(end)-n2(end);
x2 = [zeros(1,c),x2];
n2(end)=n1(end);
elseif(n2(end)>n1(end))
d = n2(end)-n1(end);
x1 = [zeros(1,d),x1];
n1(end)=n2(end);
end
n= n1(1):n2(end);
x= x1 + x2;
stem(n,x)
end

4
Task-5:
Let
Determine and plot the following sequences

Part a:
CODE:
x = [1 2 3 4 5 6 7 6 5 4 3 2 1];
l = length(x)
k=5
[y,n] = sshift( x,k )
z1=2*y
subplot(3,1,3)
stem(n,z1)
title('2x(n-5))')

5
x = [1 2 3 4 5 6 7 6 5 4 3 2 1];
l = length(x)
k=-4
[y,n] = sshift( x,k )
z2=3*y
subplot(3,1,3)
stem(n,z2)
title('3x(n+4))')

z=z1-z2
stem(n,z)
title('z1-z2')

Part b:
CODE:
x = [1 2 3 4 5 6 7 6 5 4 3 2 1];
l = length(x)
k=-3
[y,n] = sshift( x,k )
stem(-n,y)
title('x(3-n))')

6
x = [1 2 3 4 5 6 7 6 5 4 3 2 1];
l = length(x)
k=2
[y1,n] = sshift( x,k )

k=-3
[y,n] = sshift( x,k )
subplot(3,1,1)
stem(-n,y)
title('x(3-n))')
k=2
[y1,n] = sshift( x,k )
y3=y1.*x
subplot(3,1,2)
stem(n,z)
title('x(n)x(n-2)')
z=y+y3
subplot(3,1,3)
stem(n,z)
title('z')

7
CRITICAL ANALYSIS/CONCLUSION:
In this lab we studied about the basic operations of signals on MATLAB which are shifting,
reversal, scaling, addition, and multiplication. The signal can be shifted towards right or left.
Reversal is the mirror image of the original signal.

You might also like