You are on page 1of 3

Experiment 13

Object: Generate Gaussian distributed numbers and uniformly distributed numbers and find the correlation
between them.

Software Used: MATLAB

Theory: In signal processing, cross-correlation is a measure of similarity of two waveforms as a function of a time-lag applied to one of them. This is also known as a sliding dot product or sliding inner-product. It is commonly used for searching a long-signal for a shorter, known feature. It also has applications in pattern recognition, single particle analysis, electron topographic averaging, cryptanalysis, and neurophysiology. For continuous functions, f and g, the cross-correlation is defined as:

where f * denotes the complex conjugate of f. Similarly, for discrete functions, the cross-correlation is defined as:

Correlation is calculated same as convolution by matrix method just by taking the mirror image of second input sequence.

36

Source Code:clear all; close all; clc; x=normrnd(0,4,1,10); h=unidrnd(8,1,10); b=length(x); c=length(h); u=b+c-1; for i=1:c h1(i)=h(c-i+1); end; for i=1:b for j=1:c f(j,i) = x(i) .* h1(j); end; end; for a=1:u y(a)=0; for i=1:b for j=1:c if(i+j) == a+1; y(a)=y(a) + f(j,i); end; end; end; end; subplot(2,2,1); stem(x); xlabel('<---- n --->'); ylabel('<---- x[n] ---->'); title('Gaussian Distribution x[n]'); subplot(2,2,2); stem(h); xlabel('<---- n -->'); ylabel('<---- h[n] -->'); title('Uniform Distribution h[n]'); subplot(2,2,3); stem(y); xlabel('<--- n --->'); ylabel('<--- y[n] --->'); title('Output Correlation sequence y[n] using Convolution');
37

subplot(2,2,4); stem(xcorr(x,h)); xlabel('<--- n --->'); ylabel('<--- y[n] --->'); title('Output Correlation sequence y[n] using inbuilt fuction');

Results:

Conclusion: The Correlation sequence y[n] was generated of two sequences x[n] and h[n] using Matrix
Multiplication and then was verified using inbuilt MATLAB Function.
38

You might also like