Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: autocorrelation of sine function
Date: Thu, 13 Mar 2008 12:56:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 38
Message-ID: <frb892$pf5$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1205412962 26085 172.30.248.38 (13 Mar 2008 12:56:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Mar 2008 12:56:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1216156
Xref: news.mathworks.com comp.soft-sys.matlab:457012



Hello,

I'm trying to validate the xcorr function in MATLAB with a 
simple signal of a sine function. As from the theoretical 
result, the autocorrelation of Asin(wt) will give A^2/2cos
(w*tau).  
However, when I computed these command,  

%%%%%%%% Input parameters %%%%%%%
SR=1000                                
T =1/SR                                
L=1000                                 
TT=(-L:L-1)*T                           
fs=100                                  
As=1                                    
%%%%%%%% Creating Signal %%%%%%%
signal= As*sin(2*pi*fs*TT)
signal= signal(:);
%%%%%%%%%%%%%%%%% Plotting the created  signal
figure(1); plot(TT,signal)              
xlabel('Time (s)')
ylabel('Y(t)')
%%%%% Calculating the auto-correlation of the signal %%%%%
[c,lags]=xcorr(signal,'coeff');
figure(2); plot(lags,c);
xlabel('\tau (s)')
ylabel('normalised correlation, R')

The autocorrelation plot (figure(2)) results in a cosine 
function multiple with some exponential function (which 
tends to zero).It suppose to result in a continuous 
periodic function of cosine. So, i'm not sure what is 
MATLAB actually doing when determining/plotting an 
autocorrelation. Could anyone help me with this? 

Many thanks.