How to clean up the repeating element in an array?

1 vue (au cours des 30 derniers jours)
Sotheara Oum
Sotheara Oum le 27 Juin 2022
Commenté : Sotheara Oum le 27 Juin 2022
I have a variable x = [0 0 0 0 2 2 4]
I want to create another varible v that stores only the different element inside x which mean v = [0 2 4]
How to do that?

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Juin 2022
x = [0 0 0 0 2 2 4]
x = 1×7
0 0 0 0 2 2 4
v = unique(x)
v = 1×3
0 2 4
  3 commentaires
Walter Roberson
Walter Roberson le 27 Juin 2022
x = [ 0 0 2 5 1 1]
x = 1×6
0 0 2 5 1 1
v = unique(x, 'stable')
v = 1×4
0 2 5 1
Sotheara Oum
Sotheara Oum le 27 Juin 2022
Thanks a lot.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Operators and Elementary Operations 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!

Translated by