필터 지우기
필터 지우기

Find correlation coefficient between a row in a data and every row in another data

조회 수: 3 (최근 30일)
Learning
Learning 2022년 8월 23일
답변: Chunru 2022년 8월 23일
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.

답변 (1개)

Chunru
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, :)
V = 3×5
-0.9015 -0.5471 0.5020 -0.1547 2.1284 1.0707 -1.6141 1.0989 1.5863 -0.8187 -1.1413 0.3543 -1.0398 0.1434 0.8906

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by