Azzera filtri
Azzera filtri

Remove repeating variables and replacing them

2 visualizzazioni (ultimi 30 giorni)
Ex: In the array
x=[4 4 5 5 1 2 2 3 3 3 4 5]
, i want to eliminate all repeating elements and retain non-repeating elements
(4, 5,1,2,3,4,5)
i.e., If
x=[4 4 5 5 1 2 2 3 3 3 4 5]
, answer should be
x=[4 5 1 2 3 4 5]

Risposta accettata

Bruno Luong
Bruno Luong il 22 Ago 2020
x = x([true diff(x)~=0])

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by