フィルターのクリア

For loop to correlate column 1 in variable 1 to column 2 in variable 2 and so on.

3 ビュー (過去 30 日間)
JM
JM 2018 年 6 月 21 日
回答済み: Jeff Miller 2018 年 6 月 22 日
I have two variables (A and B) that store 3000x30 data points. I'm interested in creating a for loop that stores the correlation coefficient for a correlation between the data in column 1 of variable A to column 1 in variable B, column 2 A and column 2 B, etc.
Currently I have...
for i=1:30
C(i) = corrcoef(A(:,i),B(:,i))
end
--- However it does not work. I believe the issue is because corrcoef gives 4 values in a 2x2 matrix, but I am only interested in the one value that is the correlation coefficient.
Thank you!

回答 (1 件)

Jeff Miller
Jeff Miller 2018 年 6 月 22 日
for i=1:30
tmp = corrcoef(A(:,i),B(:,i));
C(i) = tmp(1,2);
end

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by