You are on page 1of 10

EXPERIMENT NO.

2A
Correlation of Signals

Aim: To determine the auto and cross correlations of any two sequences
manually using a method other than matrix multiplication and verify the results
using MATLAB.
Apparatus Required: MATLAB R2016A, Windows 10- 64 bit operating system
Theory: Correlation is a measure of similarity between two signals. The general
formula for correlation is
∫x1(t)x2(t−τ)dt
There are two types of correlation:
 Auto correlation: It is defined as correlation of a signal with itself. Auto
correlation function is a measure of similarity between a signal & its time
delayed version. It is represented with R(τ).
 Cross correlation: Cross correlation is the measure of similarity between
two different signals.
Procedure: First we clear the command window and delete all the previous
variables. Then we find the auto correlation of [1 2 3 4] and plot the graph by
the stem() function. We find the cross correlation of [1 2 3 4] and [4 5 8 9] and
plot the graph by the stem() function.
Manual calculations:
MATLAB program:
%Program for Auto correlation
clc;
clear all;
close all;
x=[1 2 3 4];
L1=length(x);
n1=0:1:L1-1;
subplot(3,1,1);
stem(n1,x);
xlabel('Time');
ylabel('Amplitude');
title('X Sequence');
L1=length(x);
n1=0:1:L1-1;
n2=n1;
subplot(3,1,2);
stem(n2,x);
xlabel('Time');
ylabel('Amplitude');
title('h Sequence');
n=min(n1)-max(n2):1:max(n1)-min(n2);
y=xcorr(x)
subplot(3,1,3);
stem(n,y);
xlabel('Time');
ylabel('Amplitude');
title('Auto correlated sequence');

%Program for Cross correlation


clc;
clear all;
close all;
x=[1 2 3 4];
h=[4 5 8 9];
L1=length(x);
n=0:1:L1-1;
subplot(3,1,1);
stem(n,x);
xlabel('Time');
ylabel('Amplitude');
title('X Sequence');
L2=length(h);
n=0:1:L2-1;
subplot(3,1,2);
stem(n,h);
xlabel('Time');
ylabel('Amplitude');
title('h Sequence');
for i=1:L1;
for j=1:L2;
y(i,i+j-1)=x(i)*h(L2-j+1);
end
end
y=xcorr(x,h);
subplot(3,1,3);
stem(y);
xlabel('Time');
ylabel('Amplitude');
title('Auto correlated sequence');

Output:
y=

4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000


Result: From this experiment, I was able to determine the auto and cross
correlations of any two sequences manually using a method other than matrix
multiplication and verify the results using MATLAB.
Inference: By the help of this experiment, we can better understand signal
detectors as correlation is used in signal detectors.
References:
1. Signals and Systems by P. Ramesh Babu and R. Anandanatarajan(4th
Edition)
2. Digital Signal Processing by P. Ramesh Babu(4th Edition)

EXPERIMENT NO. 2B
Spectral analysis of signals
Aim: To write a MATLAB R2017b program to generate a sinusoidal signal
which contains 100Hz, 150Hz, 200Hz and 250Hz frequencies.
Apparatus Required: MATLAB R2016A, Windows 10- 64 bit operating system
Theory: According to Fourier analysis any physical signal can be decomposed
into a number of discrete frequencies, or a spectrum of frequencies over a
continuous range. The statistical average of a certain signal or sort
of signal (including noise) as analyzed in terms of its frequency content, is
called its spectrum.
Procedure: First we clear the command window and delete all the previous
variables. Then we write a program to generate a sinusoidal signal which
contains 100Hz, 150Hz, 200Hz and 250Hz frequencies and then we analyze the
frequency components present in the signal with and without AWGN for a SNR
of 0.8.
MATLAB program:
%Spectral analysis of sinusoidal signals
clc;
clear all;
close all;
t=0:200;
n=256;
fs=2000;
s1=sin(2*pi*100*t/fs);
subplot(5,1,1);
plot(s1);
title('s1-100hz signal');
s2=sin(2*pi*150*t/fs);
subplot(5,1,2);
plot(s2);
title('s2-150hz signal');
s3=sin(2*pi*200*t/fs);
subplot(5,1,3);
plot(s3);
title('s3-200hz signal');
s4=sin(2*pi*250*t/fs);
subplot(5,1,4);
plot(s3);
title('s4-250hz signal');
s=s1+s2+s3+s4;
subplot(5,1,5);
plot(s);
f=fft(s,n);
d=abs(f);
figure(2);
h=0:fs/n:(fs-(fs/n));
plot(h,d);
title('Spectra of the sum of the Signals');
xlabel('Frequency');
ylabel('Magnitude');

sn=awgn(s,0.8);
fn=fft(sn,n);
dn=abs(fn);
figure(3);
subplot(2,1,1);
plot(s,'b');
hold on;
plot(sn,'r');
title('Input signal noise signal');
subplot(2,1,2);
plot(h,dn);
title('Spectra of the input signal with noise');

Output:
Result: From this experiment, I was able to understand how to write a
MATLAB R2017b program to generate a sinusoidal signal which contains
100Hz, 150Hz, 200Hz and 250Hz frequencies.
Inference: From this experiment, I was able to understand the spectral analysis
of a signal which is fundamental in electrical engineering, especially
in electronic communication systems, including radio communications, radars,
and related systems, plus passive remote sensing technology.
References:
1. Signals and Systems by P. Ramesh Babu and R. Anandanatarajan(4th
Edition)
2. Digital Signal Processing by P. Ramesh Babu(4th Edition)

You might also like