Calculating autocorrelation on time series data

Hi,
I am extremely new to matlab. For part of my research work I urgently need to calculate the autocorrelation values for time series data which are in the following form.
time(femtoseconds) distance (Angstrom)
0 15.769
100 16.160
200 15.571
300 15.816
400 15.702
...... ......
...... ......
49990 15.907
I want to calculate the autocorrelation for these distance data points which have been obtained at 100 femtosecond intervals (there are 5000 distance points).
Assuming that I am a beginner to matlab could anyone of you suggest a way to calculate the autocorrelation for these time-series distance data using matlab?
I really appreciate this help.
Thank you
Sajeewa Dewage

Answers (2)

If you have the Signal Processing Toolbox, you can use xcorr() to find the autocorrelation sequence.
If you have the Econometrics Toolbox, there is an autocorr function.

3 Comments

Hi Wayne,
Thank you very much for the quick reply. I am having difficulty in figuring out what nLags, M and nSTDs mean with respect to my data above to implement the autocorr function.
The 'series' attribute of autocorr refers to the set of distance values.
I looked up the definition of the function autocorr at http://www.mathworks.com/help/econ/autocorr.html but the definitions of nLags, M and nSTDs seem too abstract for me. Could you please explain the meanings of those three attributes in simpler terms with respect to my problem. I would really appreciate that.
Thank you
Sajeewa
Hi Wayne,
As I have 5000 data points, the value of nLags is 4999.
But in deciding M, the I can safely assume that the system would be relaxed (autocorrelation is lost)after 4000 steps. So in that sense would my value of M be 4000? (that is what I understand from the definitions given in Matlab for the attribute definitions)
I guess the two standard deviations would be good enough, so my nSTDs would be 2 (which is the default).
I am still uncertain about the value of 4000 for M. If I overestimate M, would it affect the resultant correlation values a lot?
Thank you
Sajeewa
Do you want to use autocorr() or xcorr()? Please answer that question first. Please confirm which toolboxes you have installed and which function you prefer to use.
hi Sajeewa,
try :
c=xcorr(distance,'biased'); % biased estimate

1 Comment

Hi Youssef,
The autocorrelation values calculated in the above way are not between 0 and 1. What I really want to do is to plot the autocorrelation function against time and then find the time at which the value of autocorrelation goes from 1 to 0. Could you please advise me as to how to achieve this? I really appreciate your help.
Thank you
Sajeewa

This question is closed.

Asked:

on 17 May 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!