Remove repeating variables and replacing them

1 visualización (últimos 30 días)
AA
AA el 22 de Ag. de 2020
Editada: Walter Roberson el 22 de Ag. de 2020
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]

Respuesta aceptada

Bruno Luong
Bruno Luong el 22 de Ag. de 2020
x = x([true diff(x)~=0])

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by