Remove duplicate values, but keep the initial
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
For example, i have
x = [0 0 0 1 1 0 0 0 1 0 1 0]
I want the index of the first zero or one, but not the duplicates.
So the vector should become:
0 1 0 1 0 1 0
Where the indices would be '1 4 6 9 10 11 12'
Thanks
0 commentaires
Réponse acceptée
Plus de réponses (1)
Jan
le 28 Fév 2017
x = [0 0 0 1 1 0 0 0 1 0 1 0]
[B, N, Index] = RunLength(x)
Then B contains the unique values and Index the indices.
0 commentaires
Voir également
Catégories
En savoir plus sur Elementary Math dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!