필터 지우기
필터 지우기

How to calculate moving covariance in a matrix?

조회 수: 3 (최근 30일)
Andrea Finocchiaro
Andrea Finocchiaro 2015년 10월 9일
댓글: Andrea Finocchiaro 2015년 10월 9일
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
Image Analyst
Image Analyst 2015년 10월 9일
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 2015년 10월 9일
Yes,correct that is the moving window I mena. But why correlation?I am looking for the Covarinces

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2015년 10월 9일
% 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by