How to extract the most similar(closest) one

1 回表示 (過去 30 日間)
Mekala balaji
Mekala balaji 2017 年 8 月 28 日
回答済み: Stephen23 2017 年 8 月 28 日
Hi,
I have below matrix:
InputMatrix:
1.0 2.2 3.1 4.0
1.1 3.3 4.7 6.2
2.2 4.9 5.3 6.2
1.1 2.3 2.8 3.9
Now I have the new one
Newdata:
1.2 2.2 3.4 4.5
I want to extract most similar row in InputMatrix to New data,

採用された回答

Stephen23
Stephen23 2017 年 8 月 28 日
To obtain the closest row without requiring a tolerance value:
M = [1.0,2.2,3.1,4.0;1.1,3.3,4.7,6.2;2.2,4.9,5.3,6.2;1.1,2.3,2.8,3.9];
V = [1.2,2.2,3.4,4.5];
[~,idx] = min(sum(bsxfun(@minus,M,V).^2,2));
M(idx,:)

その他の回答 (1 件)

KSSV
KSSV 2017 年 8 月 28 日
編集済み: KSSV 2017 年 8 月 28 日
Read about ismembertol ....
A = [1.0 2.2 3.1 4.0
1.1 3.3 4.7 6.2
2.2 4.9 5.3 6.2
1.1 2.3 2.8 3.9] ;
B = [1.2 2.2 3.4 4.5] ;
idx = ismembertol(A, B, 0.1, 'ByRows', true)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by