Effacer les filtres
Effacer les filtres

Check if there are repeated elements in a vector

45 vues (au cours des 30 derniers jours)
Max
Max le 4 Déc 2012
Commenté : Image Analyst le 25 Nov 2021
Hi to all, is there a command to check if there are repeated elements in a vector; I just have to check in an "if"...
thanks a lot
Max

Réponse acceptée

Image Analyst
Image Analyst le 4 Déc 2012
if length(v) == length(unique(v))
% There are no repeats.
.......
  6 commentaires
Yasir Iqbal
Yasir Iqbal le 25 Nov 2021
You can simply craete a copy of the vector with the required amount of values. There can be other ways around also. Just a suggestion.
Image Analyst
Image Analyst le 25 Nov 2021
@Larissa Monjaraz I don't understand because you forgot to provide your example with actual numbers. So about all I can say is to try ismember().

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