How to calculate autocorrelation for each column of matrix?
3 次查看(过去 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.
0 个评论
回答(1 个)
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!