How to calculate autocorrelation for each column of matrix?

6 次查看(过去 30 天)
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.

回答(1 个)

Image Analyst
Image Analyst 2018-12-14
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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by