0% found this document useful (0 votes)
88 views5 pages

Experiment 4

The document describes experiments performed in MATLAB to analyze digital signals: 1) An autocorrelation of a given sequence is computed and its properties like being even and its relation to the energy of the signal are verified. 2) The autocorrelation of a sine wave is plotted by generating the sine wave with a sampling frequency of 200 Hz and computing its autocorrelation. 3) The cross correlation between a sine wave and the same sine wave with added Gaussian noise is plotted by generating the signals and computing their cross correlation.

Uploaded by

Manthan Pandhare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views5 pages

Experiment 4

The document describes experiments performed in MATLAB to analyze digital signals: 1) An autocorrelation of a given sequence is computed and its properties like being even and its relation to the energy of the signal are verified. 2) The autocorrelation of a sine wave is plotted by generating the sine wave with a sampling frequency of 200 Hz and computing its autocorrelation. 3) The cross correlation between a sine wave and the same sine wave with added Gaussian noise is plotted by generating the signals and computing their cross correlation.

Uploaded by

Manthan Pandhare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Digital Signal Processing

Name-Nupur Padvi
M.I.S no.-112007041
Branch- TY ENTC

Experiment 4:-
Aim:Autocorrelation of a given sequence and verification of its properties.
Software Required: MATLAB

Program:
Autocorrelation of a given sequence and verification of its properties.

% Read the signal


x=[1,2,3,6,5,4]
% define the axis
n=0:1:length(x)-1
% plot the signal
stem(n,x);
xlabel('n');
% auto correlate the signal
Rxx=xcorr(x,x);
% the axis for auto correlation results
nRxx=-length(x)+1:length(x)-1
% display the result
stem(nRxx,Rxx)
% properties of Rxx(0) gives the energy of the signal
% find energy of the signal
energy=sum(x.^2)
%set index of the centre value
centre_index=ceil(length(Rxx)/2)
% Acces the centre value Rxx(0)
Rxx_0==Rxx(centre_index)
Rxx_0==Rxx(centre_index)
% Check if the Rxx(0)=energy
if Rxx_0==energy
disp('Rxx(0) gives energy proved');
else
disp('Rxx(0) gives energy not proved');
end
Rxx_right=Rxx(centre_index:1:length(Rxx))
Rxx_left=Rxx(centre_index:-1:1)
ifRxx_right==Rxx_left
disp('Rxx is even');
else
disp('Rxx is not even');
end

Output:-

Graph:-
Autocorrelation of a sinewave
Plot the autocorrelation sequence of a sinewave with frequency 1 Hz, sampling frequency of
200 Hz.
The Matlab program is listed below:

N=1024; % Number of samples


f1=1; % Frequency of the sinewave
FS=200; % Sampling Frequency
n=0:N-1; % Sample index numbers
x=sin(2*pi*f1*n/FS); % Generate the signal, x(n)
t=[1:N]*(1/FS); % Prepare a time axis
subplot(2,1,1); % Prepare the figure
plot(t,x); % Plot x(n)
title('Sinwave of frequency 1000Hz [FS=8000Hz]');
xlabel('Time, [s]');
ylabel('Amplitude');
grid;
Rxx=xcorr(x); % Estimate its autocorrelation
subplot(2,1,2); % Prepare the figure
plot(Rxx); % Plot the autocorrelation
grid;
title('Autocorrelation function of the sinewave');
xlable('lags');
ylabel('Autocorrelation');

Output
Cross correlation

Plot the cross correlation of the following signal:


x(n)= sin(2П f1t ) with f1 Hz
y( n )= x( n )+ w( n )

wherew(n) is a zeros mean, unit variance of Gaussina random process


N=1024; % Number of samples to generate
f=1; % Frequency of the sinewave
FS=200; % Sampling frequency
n=0:N-1; % Sampling index
x=sin(2*pi*f1*n/FS); % Generate x(n)
y=x+10*randn(1,N); % Generate y(n)
subplot(3,1,1);
plot(x);
title('Pure Sinewave');
grid;
subplot(3,1,2);
plot(y);
title('y(n), Pure Sinewave + Noise');
grid;
Rxy=xcorr(x,y); % Estimate the cross correlation
subplot(3,1,3);
plot(Rxy);
title('Cross correlation Rxy');
grid;

Output:-

You might also like