# Hamming distance between columns of two matrices

3 ビュー (過去 30 日間)
riad didou 2021 年 11 月 10 日

Hii
%Just an example
HamDist = pdist2(B,C,'hamming');
[~,ind] = min(HamDist,[],2);
Is there any trick to perform hamming distance between columns of two different binary matrices: A(64 by100) and B(64 by 80), and report the minimum distances?
To understand more : the "A" is a data matrix with 100 sample, and the B has 80 cluster centroids and in terms of clustering i would like to create the indicator matrix based on the minimum distance between A and B.
##### 2 件のコメントなしを表示なしを非表示
Awais Saeed 2021 年 11 月 10 日
How aboout padd some zeros in B to make size(A)=size(B) and then find the hamming distance
riad didou 2021 年 11 月 10 日
To understand more : the "A" is a data matrix with 100 sample, and the B has 80 cluster centroids and in terms of clustering i would like to create the indicator matrix based on the minimum distance between A and B.

サインインしてコメントする。

### 回答 (1 件)

KSSV 2021 年 11 月 10 日
HamDist = pdist2(A',B','hamming');
HamDist = HamDist' ;
[~,ind] = min(HamDist,[],2);
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
riad didou 2021 年 11 月 10 日
but the result of the first line is a real values (HamDist )!!

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeHamming についてさらに検索

R2019b

### Community Treasure Hunt

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

Start Hunting!

Translated by