How Can I Calculate Correlation Coefficients for large matrix column-wise?
2 次查看(过去 30 天)
显示 更早的评论
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(:,:))
0 个评论
回答(1 个)
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!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!