Find correlation coefficient between a row in a data and every row in another data
6 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have two data sets, data A an B. Data A has just a single row with 5 columns. Data B has 10 rows each with 5 columns as well. I want to find the correlation coefficients between row 1 in A and row 1 in B, then between row 1 in A and row 2 in B...till the corrcoeff between row 1 in data A and every row in data B has been computed.
After that, I want to extract those rows in B which had the highest correlation coefficient (>=0.8) with row 1 in A into another matrix called C.
Any idea would be appreciated!
Thank you.
0 件のコメント
回答 (1 件)
Chunru
2022 年 8 月 23 日
A = randn(1, 5);
B = randn(10, 5);
r = zeros(10,1);
for i=1:10
tmp = corrcoef(A, B(i, :));
r(i) = tmp(1,2);
end
idx = (abs(r) > 0.5); % change the threshold here
V =B(idx, :)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!