Effacer les filtres
Effacer les filtres

how to calculate hamming distance between vectors in matrix

13 vues (au cours des 30 derniers jours)
jim
jim le 19 Oct 2014
i try this code as:
a = [1 0 1 0 1;
0 1 1 1 0;
1 1 0 0 1];
D = pdist(a,'minkowski',1)
the answer came as: 4 2 4 while it should be : 0 4 4 how to solve it? and to make run for bigger matrix as (50x30)
  1 commentaire
Deeksha Varshney
Deeksha Varshney le 2 Nov 2017
firstly change minkowski to hamming then may be you will get correct answer.

Connectez-vous pour commenter.

Réponse acceptée

the cyclist
the cyclist le 19 Oct 2014
Modifié(e) : the cyclist le 19 Oct 2014
Well, this doesn't give your expected output, but
D = pdist(a,'hamming')
gives the Hamming distance between each pair of rows.
I'm not sure why you used the input argument "minkowski".
You can see details in the documentation.
  12 commentaires
jim
jim le 21 Oct 2014
Modifié(e) : jim le 21 Oct 2014
it works right now... thanks alot
the cyclist
the cyclist le 21 Oct 2014
The best form of thanks to accept the answer, which indicates to others (who may have a similar problem) that this resolved the question you posed.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by