how to calculate element distance in a vector?
Afficher commentaires plus anciens
hi guys i want to calculate the difference between vector element as [0 1 1 0 1 1 0] which should give 0-1=1,1-1=0,1-0=1,0-1=1,1-1=0,1-0=1,,, and the sum answer should be 4. how to do this. and what if there's 12 vector within one matrix.
Réponse acceptée
Plus de réponses (1)
W. Owen Brimijoin
le 21 Oct 2014
Try this:
answer = sum((abs(diff(M,1,2))),2)
1 commentaire
sara
le 21 Oct 2014
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!