Professional Documents
Culture Documents
DSP Lab Report 4 20-CP - 56
DSP Lab Report 4 20-CP - 56
TAXILA
Submitted by:
19-CP-01
Anam Arshad
Submitted to:
Sir Amir Arslan
Lab Tasks:
Task 01 :
Code:
function y=my_convolution(x,h)
C=[];
for i=1:length(x)
z=h.*x(i);
C=[C;z];
end
[row,col]=size(C);
k=row+col;
t=2;
y=[];
cd=0;
while(t<=k)
for i=1:row
for j=1:col
if ((i+j)==t)
cd=cd+C(i,j);
end
end
end
t=t+1;
y=[y cd];
cd=0;
end
disp(y)
stem(y)
end
Output:
When input is given in form of signal x[n] and h[n] . The output is convolution of both signals
in time domain y[n]=x[n]*h[n]. In coding there are loops if condition and while loop also. The
matrix C is defined initially to 0.Then after it checks the condition and run the loop, each value
that is calculated is stored in cd matrix modification of C matrix.
Y[n]=x[n]*h[n]
Task 02:
Output:
Task 03:
Output:
Commutative:
x[n]*h[n]=h[n]*x[n]