0% found this document useful (0 votes)
43 views1 page

Ronaldcode

This document contains code to calculate the autocorrelation of an input signal, plot the input signal and its autocorrelation, and verify two properties of the autocorrelation: 1) the autocorrelation at lag 0 equals the energy of the signal, and 2) the autocorrelation is even. The user is prompted to enter a signal, which is then autocorrelated using the xcorr function and plotted along with the original signal. The autocorrelation at lag 0 is checked against the energy of the signal and the left and right halves are compared to test for even symmetry.

Uploaded by

Ronald Lugwire
Copyright
© Attribution Non-Commercial (BY-NC)
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)
43 views1 page

Ronaldcode

This document contains code to calculate the autocorrelation of an input signal, plot the input signal and its autocorrelation, and verify two properties of the autocorrelation: 1) the autocorrelation at lag 0 equals the energy of the signal, and 2) the autocorrelation is even. The user is prompted to enter a signal, which is then autocorrelated using the xcorr function and plotted along with the original signal. The autocorrelation at lag 0 is checked against the energy of the signal and the left and right halves are compared to test for even symmetry.

Uploaded by

Ronald Lugwire
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 1

clear clc close all %READ THE INPUT SIGNAL x=input('Enter the sequence'); %Define the axis n=0:1:length(x)-1;

%PLOT THE SIGNAL subplot(2,1,1); stem(n,x); xlabel('n--->'); ylabel('x--->'); title('sequence x'); grid on; %AUTOCORRELATE THE SIGNAL Rxx=xcorr(x,x); %AXIS FOR THE AUTOCORRELATION RESULT nRxx=-length(x)+1:length(x)-1; %Display the result subplot(2,1,2); stem(nRxx,Rxx); xlabel('nRxx--->'); ylabel('autocorrelation of x--->'); title('Autocorrelated sequence of x'); grid on;

%%VERAFICATION OF THE AUTOCORRELATION PROPERTIES %PROPERTY-1:RXX(0) GIVES THE ENERGY OF THE SIGNAL %Energy OF THE SIGNAL = SUM(SQUARE OF X) energy = sum(x.^2); %GET THE INDEX OF THE CENTER VALUE center_index = ceil(length(Rxx)/2) %ACCESS CENTER VALUE RXX(0) Rxx_0=Rxx(center_index) %CHECK IF THE RXX(0)=ENERGY if Rxx_0==energy disp('Rxx(0) gives energy -- propert-1 is proved'); else disp('Rxx(0) gives energy -- propert-1 is not proved'); end %PROPERTY-2:RXX IS EVEN Rxx_Right = Rxx(center_index:length(Rxx)); Rxx_left = Rxx(center_index:-1:1); if Rxx_Right==Rxx_left disp('Rxx is even'); else disp('Rxx is not even'); end

You might also like