How Can I Calculate Correlation Coefficients for large matrix column-wise?

조회 수: 4 (최근 30일)
Isa Samad
Isa Samad 2020년 10월 8일
답변: Luciano Garim 2020년 10월 8일
Hi there,
I'm still somewhat new to using MATLAB for quantitative analysis but I have a 800 x 43 matrix called M. I would like to calculate the correlation coefficients for every term in a single row for all 800 rows (left to right) such that after inputting it into the command window, I receive an 800 x 1 vector. For example in the 1st row, I want to calculate how the coefficients between all 44 values from left to right in that 1st row and repeat that for each row after. Is this possible in MATLAB using the corrcoef function? Currently I've tried both of these inputs, however, I receive a 43 x 43 matrix upon entering the commands instead of a 800 x 1 column vector.
R = corrcoef(M(1:800,:))
R = corrcoef(M(:,:))

답변 (1개)

Luciano Garim
Luciano Garim 2020년 10월 8일
Hi, Isa Samad!
If I understood your problem, you may solve it using the next few lines:
for i=1:size(M,1)
corelation(:,i)=corrcoef(M(i,:))
end
I hope helped you!

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by