How to calculate autocorrelation for each column of matrix?
5 views (last 30 days)
Show older comments
Hello, I have 31x14 matrix. And I am trying to calculate autocorrelation lag 1 seperately for each 14 column's. I mean, I want to obtain autocorrelation matrices in 1x14 matrix form.
autocorr(a,'NumLags',1)
With this function, ''The value of 'y' is invalid. Expected input series to be a vector.'' error occured. What should I do to calculate each column's autocorrelation?
Thanks in advance.
0 Comments
Answers (1)
Image Analyst
on 14 Dec 2018
I don't have your autocorr() function, but I guess it'd go something like this:
data = rand(31, 14) % Create random data for demo.
[rows, columns] = size(data)
for col = 1 : columns
thisColumn = data(:, col);
% Call your custom-written function, autocorr().
someOutput = autocorr(thisColumn, 'NumLags', 1)
% Now do something with someOutput.
end
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!