how to calculate element distance in a vector?
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
W. Owen Brimijoin
am 21 Okt. 2014
Try this:
answer = sum((abs(diff(M,1,2))),2)
1 Kommentar
sara
am 21 Okt. 2014
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!