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

4 Ansichten (letzte 30 Tage)
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(:,:))

Antworten (1)

Luciano Garim
Luciano Garim am 8 Okt. 2020
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!

Community Treasure Hunt

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

Start Hunting!

Translated by