I have Two matrix A &B as follows"
A=[1.2 2.0 3.3;1.2 2.0 3.2;1.1 2.1 3.3]
B=[1.1 2.0 3.2]
I want to find most similar row in matrix A(&elements) to matrix B. Please kindly help some how can I trace the most similar one.
Many Thanks in advance.

댓글 수: 2

How you quantify the similarity?
A = [1 1 1];
B = [1 1 1e6];
C = [10 10 10];
Which of B or C is "most similar" to A? B matches two of the three elements exactly, but the third is rather far off. C doesn't match ANY of the elements in A exactly, but it's not as far off as B's third element.

댓글을 달려면 로그인하십시오.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 7월 1일
variant
A=[1.2 2.0 3.3;1.2 2.0 3.2;1.1 2.1 3.3];
B=[1.1 2.0 3.2];
a = sqrt(sum(bsxfun(@minus,A,B).^2));
[~,t] = min(a);
out = A(t,:);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

질문:

2015년 7월 1일

댓글:

2015년 7월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by