0% found this document useful (0 votes)
15 views11 pages

Exp 4

This document describes MATLAB functions to manipulate discrete-time signals. It includes functions to add, subtract, multiply, shift, and fold two discrete sequences. It also describes how to find the even and odd parts of a discrete-time signal by expressing the signal as the sum of its even and odd components. Code examples are provided to demonstrate applying the functions and separating a signal into its even and odd parts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views11 pages

Exp 4

This document describes MATLAB functions to manipulate discrete-time signals. It includes functions to add, subtract, multiply, shift, and fold two discrete sequences. It also describes how to find the even and odd parts of a discrete-time signal by expressing the signal as the sum of its even and odd components. Code examples are provided to demonstrate applying the functions and separating a signal into its even and odd parts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

International Islamic University Chittagong

Dept. of Electrical and Electronic Engineering

Experiment-4
Manipulation of Discrete-Time (DT) signals

EEE-3604 Digital Signal Processing Sessional

Prepared By
Mohammed Abdul Kader
Assistant Professor, Dept. of EEE, IIUC
Objectives
a) To develop MATLAB program to add/subtract/multiply two discrete time sequence.
b) To develop function to shift and fold DT sequence.
c) To develop the function to find the symmetric (even) and anti-symmetric (odd) part of
DT signal.

2 Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Addition
Function
function [y,n]=sigadd(x1,n1,x2,n2)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));
y2=y1;
y1((n>=min(n1))&(n<=max(n1)))=x1;
y2((n>=min(n2))&(n<=max(n2)))=x2;
y=y1+y2;

Command Window
>> n1=-3:2;
>> x1=[1,5,4,3,7,0];
>> n2=-5:5;
>> x2=[0 1 2 3 3 9 8 5 5 4 4]; >> stem(n2,x2);
>> [y,n]=sigadd(x1,n1,x2,n2); >> title('Signal x2(n2)');
>> subplot(311); >> subplot(313);
>> stem(n1,x1); >> stem(n,y);
>> title('Signal x1(n1)'); >> title('Signal y(n)=x1(n)+x2(n2)');
>> subplot(312);
3
Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Addition: Output

4
Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Shift
Function Command Window
function [y,n]=sigshift(x,m,k) >> n1=-3:2;
%implement y(n)=x(n-k) >> x1=[1,5,4,3,7,0];
n=m+k; >> [y1,n11]=sigshift(x1,n1,-5);
y=x; >> [y2,n22]=sigshift(x1,n1,3);
>> subplot(311);
>> stem(n1,x1);
>> title('Signal x1(n1)');
>> subplot(312);
>> stem(n11,y1);
>> title('Left shift of x1(n1)');
>> subplot(313);
>> stem(n22,y2);
>> title('Right shift of x1(n1)');

5
Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Shift: Output

6 Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Folding
Function
Command Window
function [y,n]=sigfold(x,m)
% imlementation of y(n)=x(-n) >> n2=-5:5;
[r,c]=size(x); >> x2=[0 1 2 3 3 9 8 5 5 4 4];
if c==1 >> [y,n]=sigfold(x2,n2);
y=flipud(x); >> subplot(211);
else >> stem(n2,x2);
y=fliplr(x); >> title('Signal x2(n2)');
end >> subplot(212);
[r,c]=size(m); >> stem(n,y);
if c==1 >> title('Signal y=x2(-n2)');
n=-flipud(m);
else
n=-fliplr(m);
end

7
Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Folding: Output

8 Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Finding even and odd part of DT signals

Many signal are neither even nor odd. Any arbitrary signal can be expressed as the sum of two
signal components, one of which is even and the other odd.
The even signal components is expressed as

The odd signal components is expressed as

The signal x(n) is expressed as-

9 Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Function
function [xe,ne,xo,no]=even_odd(x,n) Command Window
[X,N]=sig_fold(x,n); >> x=[-5 6 2 0 2 4 9 5];
[xe,ne]=sig_add(x,n,X,N); >> n=-1:6;
xe=0.5*xe; >> [xe,ne,xo,no]=even_odd(x,n);
[xo,no]=sig_sub(x,n,X,N); >> subplot(2,2,[1 2]);
xo=0.5*xo; >> stem(n,x);
>> title('Original Signal');
>> subplot(2,2,3);
>> stem(ne,xe);
>> title('Even Part');
>> subplot(2,2,4);
>> stem(no,xo);
>> title('Odd Part');

10 Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC
Output

11 Experiment-4, Digital Signal Processing Sessional, Prepared By- Mohammed Abdul Kader, Assistant Prof, Dept. of EEE, IIUC

You might also like