How to calculate moving covariance in a matrix?

6 Ansichten (letzte 30 Tage)
Andrea Finocchiaro
Andrea Finocchiaro am 9 Okt. 2015
Hi guys, Hi Guys, I have got a matrix :378x9. I need to calculate the moving covariance with a window size of 120(starting from row one). Can somebody help me please? Thank you very much Andrea
  4 Kommentare
Image Analyst
Image Analyst am 9 Okt. 2015
OK, so you're finding out the correlation coefficient between column 1 and col 2, col 1 and col 3, etc. But what do you mean by having a moving window? Do you want to not use the whole column, but just a subset/window of the columns, and then do it again with the window moved down until the whole column has eventually been looked at?
Andrea Finocchiaro
Andrea Finocchiaro am 9 Okt. 2015
Yes,correct that is the moving window I mena. But why correlation?I am looking for the Covarinces

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

the cyclist
the cyclist am 9 Okt. 2015
% Generate some pretend data. Use your real data here.
data = rand(378,9);
[M,N] = size(data);
window = 120;
numberCovarianceMatrices = M - window + 1;
covarianceMatrices = zeros(N,N,numberCovarianceMatrices);
for nc = 1:numberCovarianceMatrices
covarianceMatrices(:,:,nc) = cov(data(nc:(nc+window-1),:));
end

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by