Remove duplicate values, but keep the initial
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
James Boyle
am 28 Feb. 2017
Kommentiert: James Boyle
am 1 Mär. 2017
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Jan
am 28 Feb. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Elementary Math finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!