Escolar Documentos
Profissional Documentos
Cultura Documentos
IN LAB TASK
TASK#1:
Write an Example of Convolution in MATLAB
h=[1 2 3 ]; covolution
x=[2 4 6]; 25
b=conv(x,h);
n=0:1:m
20
m=length(b)-1;
stem(n,b);
xlabel('time');
15
ylabel('amplitude');
amplitude
title('covolution');
grid on; 10
0
0 0.5 1 1.5 2 2.5 3 3.5 4
tim e
TASK#2:
Write an Example of Correlation in MATLAB:
f=2;
fs=10*f; s ignal A
ts=1/fs; 1
n=0:ts:1;
siga=sin(2*pi*f*n); 0
sigb=sin(2*pi*f*n+pi);
corsig=xcorr(siga,sigb); -1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
subplot(311); s ignal B
stem(n,siga); 1
title('signal A');
0
subplot(312);
stem(n,sigb);
-1
title('signal B'); 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
subplot(313); correlated s ignal
20
stem(-20:20,corsig);
title('correlated signal') 0
grid on;
-20
-20 -15 -10 -5 0 5 10 15 20
POST LAB TASK
0
0 0.5 1 1.5 2 2.5 3
2. Create two vectors. Find the central part of the convolution of u and v that is the same size as u.
u=[2 4 6];
v=[4 2 6];
c=conv(u,v, 'same'); 45
n=length(c)-1;
m=0:1:n; 40
stem(m,c);
35
xlabel('time');
ylabel('amplitude'); 30
grid on;
amplitude
ANS: 25
20
u=[2 4 6];
v=[4 2 6]; 15
c=conv(u,v, 'same')
10
c= 5
20 44 36 0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
tim e
3. Create two vectors whereas generate those parts of the convolution that are computed
without the zero-padded edges
u=[2 4 6]; 45
v=[4 2 6];
c=conv(u,v, 'valid'); 40
n=length(c)-1;
35
m=0:1:n;
30
amplitude
25
20
15
10
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
tim e
s ignal A
1
amplitude
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
tim e
s ignal B
1
amplitude
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
tim e