Sei sulla pagina 1di 5

Experiment No.

1
Date: 1/8/19

REALIZATION OF CORRELATION

AIM:
1. Generation of signals with different amplitude and frequencies.
2. Generation of signals with multiple frequencies.
3. Performing auto and cross correlation of different signals.
4. Finding the correlation coefficient.
5. Study of correlation coefficient relationship with amplitude and frequencies.
THEORY:
Correlation quantifies the ‘linear’ relationship between two signals. It is a measure of the similarity
between two signals.
There are two types of correlation:

• Auto Correlation
• Cross Correlation
Auto Correlation is defined as correlation of a signal with itself. Auto correlation function is a measure
of similarity between a signal & its time delayed version.

Auto Correlation function of signal x 𝑆𝑥𝑥 where X is the mean value of signal x

Auto Correlation function of signal y 𝑆𝑦𝑦 where Y is the mean value of signal y
Cross correlation is the measure of similarity between two different signals.

Cross Correlation function of the two signals x and y 𝑆𝑥𝑦

Pearson’s Coefficient of Correlation (denoted by ‘𝑟’) shows the linear relationship between two sets of
data. It is defined as the covariance of the two variables divided by the product of their standard
deviations.

𝑆𝑥𝑦
𝑟=
√𝑆𝑥𝑥𝑆𝑦𝑦

If 𝑟=+1, it shows positive linear relationship


If 𝑟=-1, it shows negative linear relationship
If 𝑟=0, there is no linear relationship
𝒓 Strength of Correlation

𝟎 < |𝒓| < 𝟎. 𝟑 Weak Correlation

𝟎. 𝟑 < |𝒓| < 𝟎. 𝟕 Moderate Correlation

|𝒓| > 𝟎. 𝟕 Strong Correlation


PROCEDURE:

• Take two signals x and y of amplitude 1, having same sampling frequency of 10KHz with base
band frequency satisfying the Nyquist rate.
• Generate x1 and y1 using Mat lab and plot it.
• Find auto correlation 𝑆𝑥𝑥, 𝑆𝑦𝑦 and cross correlation 𝑆𝑥𝑦 and plot it.
• Compute the Pearson’s correlation coefficient ‘𝑟’.
• Plot the variation of ‘𝑟’ with respect to frequency ‘f’ by varying the frequency of any one of the
signal. • Plot the variation of ‘𝑟’ with respect to amplitude ‘a’ by varying the amplitude of any
one of the signal.
• Determine the strength of correlation in each of the above cases using the ‘display’ command.
• Repeat the above simulation steps by using a signal which has 2 or multiple frequencies i.e
f1,f2…etc either in x1 or x2.
• Finally write the inferences.
MATLAB CODE:
%GENERATION AND CORRELATION OF SINGLE TONE SIGNALS
f1=100; f2=200; fs=10000; ts=1/fs; t=0:ts:2*pi;
x=sin(2*pi*f1*t); y=sin(2*pi*f2*t);
X=mean(x);
Y=mean(y); sxx=sum((x-
X).^2) syy=sum((y-
Y).^2) sxy=sum((x-
X).*(y-Y))
r=sxy/(sqrt(sxx*syy))
subplot(4,2,1);
plot(t,x); xlabel('t');
ylabel('x(t)');
xlim([0 0.04]);
title('Single tone signal X');
subplot(4,2,2); plot(t,y);
xlabel('t'); ylabel('y(t)');
xlim([0 0.04]); title('Single
tone signal Y');

%VARIATION OF r WITH FREQUENCY FOR SINGLE TONE SIGNAL


rf=[]; for f3=1:400;
y1=sin(2*pi*f3*t);
syy1=sum((y1-mean(y1)).^2);
sxy1=sum((x-X).*(y1-mean(y1)));
r1=sxy1/sqrt(sxx*syy1); rf=[rf
r1]; end subplot(4,2,5); plot(rf);
xlim([0 200]); ylim([-0.05 1.05]);
xlabel('Frequency');
ylabel('Correlation Coefficient');
title('r vs f for single tone signal');

%VARIATION OF r WITH AMPLITUDE FOR SINGLE TONE SIGNAL


ra=[]; for a=1:100; y2=a*x;
syy2=sum((y2-mean(y2)).^2);
sxy2=sum((x-X).*(y2-mean(y2)));
r2=sxy2/sqrt(sxx*syy2); ra=[ra r2];
end subplot(4,2,6); plot(ra); xlim([0
100]); ylim([-2 2]);
xlabel('Amplitude');
ylabel('Correlation Coefficient');
title('r vs a for single tone signal');

%GENERATION AND CORRELATION OF A MULTITONE SIGNAL


xm=x+2*y+sin(2*pi*300*t); sxxm=sum((xm-
mean(xm)).^2) subplot(4,2,3); plot(t,xm);
xlabel('t'); ylabel('xm(t)'); xlim([0 0.06]);
title('Multi tone signal');

%VARIATION OF r WITH FREQUENCY FOR MULTI TONE SIGNAL


rfm=[]; for f4=1:400; y3=sin(2*pi*f4*t);
syy3=sum((y3-mean(y3)).^2); sxy3=sum((xm-
mean(xm)).*(y3-mean(y3)));
r3=sxy3/sqrt(sxxm*syy3); rfm=[rfm r3]; end
subplot(4,2,7); plot(rfm); ylim([-0.05 1.05]);
xlim([0 400]); xlabel('Frequency');
ylabel('Correlation Coefficient'); title('r vs f
for multi tone signal');

%VARIATION OF r WITH AMPLITUDE FOR MULTI TONE SIGNAL


ram=[]; for am=1:100; y4=am*x;
syy4=sum((y4-mean(y4)).^2);
sxy4=sum((xm-mean(xm)).*(y4-mean(y4)));
r4=sxy4/sqrt(sxxm*syy4); ram=[ram r4];
end subplot(4,2,8); plot(ram); ylim([-2
2]); xlabel('Amplitude');
ylabel('Correlation Coefficient'); title('r
vs a for multi tone signal');

RESULTS:
1. Two single tone signals x and y were generated.
𝑥 = sin(200𝜋𝑡)
𝑦 = sin⁡(400𝜋𝑡)

Auto correlation function of signal x 𝑆𝑥𝑥 = 3.1419×104


Auto correlation function of signal y 𝑆𝑦𝑦 = 3.1414×104
Cross correlation function of signals x and y 𝑆𝑥𝑦 = 8.1996
Pearson’s correlation coefficient 𝑟 = 2.61×10-4

2. A multitone signal xm was generated.


𝑥𝑚 = 𝑥 + 2𝑦 + sin(600𝜋𝑡) = sin(200𝜋𝑡) + 2 sin(400𝜋𝑡) + sin(600𝜋𝑡)

Auto correlation function of signal xm 𝑆𝑥𝑥𝑚 = 1.8855×105

3. Variation of Pearson’s correlation coefficient ′𝑟′ with frequency and amplitude for a single tone
signal was observed graphically.
i. Variation of 𝑟 with frequency for a single tone signal
On varying frequency from 1 Hz to 400 Hz value of 𝑟 ranges from -0.0069 to 1
The peak value of 1 was obtained at frequency 100 Hz

ii. Variation of 𝑟 with amplitude for a single tone signal


On varying frequency from 1 to100 units, constant 𝑟 value of 1 was obtained.

4. Variation of Pearson’s correlation coefficient ′𝑟′ with frequency and amplitude for a multi tone
signal was observed graphically.
i. Variation of 𝑟 with frequency for a multi tone signal
On varying frequency from 1 Hz to 400 Hz value of 𝑟 ranges from -0.0055 to 0.8166
The peak value of 0.8166 was obtained at frequency 200 Hz
Two smaller peaks are obtained at frequencies 100 Hz and 300 Hz
ii.
Variation of 𝑟 with amplitude for a multi tone signal
On varying frequency from 1 to100 units, constant 𝑟 value of 0.4084 was obtained.

Potrebbero piacerti anche