Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

1D Convolution

 Convolution is used to compute the output of an


LTI system having impulse response for a given
input signal .
 The 1D Convolution of two signals and is given by

 Let we have the following signals


 The output is then given by

-1 0 1 2 3 4 5 6
0 5 4 2 3 7 4 0
1 2 3 0 0 0 0 0
5 4 2 3 7 4 0 0
0 10 8 4 6 14 8 0
0 0 15 12 6 9 21 12
5 14 25 19 19 27 29 12
1D Correlation
 Cross-correlation measures the similarity
between two signals.
 The 1D Cross Correlation between two signals
and is given by

 Let we have the following signals


 The output is then given by

-1 0 1 2 3 4 5 6
0 5 4 2 3 7 4 0
1 2 3 0 0 0 0 0
0 0 5 4 2 3 7 4
0 10 8 4 6 14 8 0
15 12 6 9 21 12 0 0
15 22 19 17 29 29 15 4
 Cross-Correlation of Two Vectors
 r = xcorr(x,y) returns the cross-correlation of two
discrete-time sequences.
 Cross-correlation measures the similarity between
a vector x and shifted (lagged) copies of a
vector y as a function of the lag.
 If x and y have different lengths, the function
appends zeros to the end of the shorter vector so
it has the same length as the other.
 Cross-Correlation of Two Vectors
 Example:
 Create a vector x and a vector y that is equal
to x shifted by 5 elements to the right.
 Compute and plot the estimated cross-correlation
of x and y.
 The largest spike occurs at the lag value when the
elements of x and y match exactly (-5).
 Cross-Correlation of Two Vectors
 MATLAB Code

n = 0:15;
x = 0.84.^n;
y = circshift(x,5);
[c,lags] = xcorr(x,y);
stem(lags,c);
 Autocorrelation of Vector
 r = xcorr(x) returns the autocorrelation sequence
of x.
 If x is a matrix, then r is a matrix whose columns
contain the autocorrelation and cross-correlation
sequences for all combinations of the columns
of x.
 Autocorrelation of Vector
 Example: Compute and plot the estimated
autocorrelation of a vector x.
 The largest spike occurs at zero lag, when x
matches itself exactly.
 MATLAB Code

n = 0:15;
x = 0.84.^n;
[c,lags] = xcorr(x);
stem(lags,c);

You might also like