How can I remove a duplicate set values?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
I have an array of
d = [100 50 100 100 50 100 100 50 100 100 50 100 100 50 100 100 50 100];
the result that I want is
d = [100 50 100]
I already tried using unique(d) but the result shows [50 100] How can I remove the duplicate values?
Thanks
3 commentaires
Rika Citra
le 20 Mai 2018
Jan
le 20 Mai 2018
Do you know the length of the sequence or does the determination of the period belongs to the problem?
Réponses (3)
Ameer Hamza
le 20 Mai 2018
For a general case, where you don't already know the number of elements being repeated use the following
d(1:seqperiod(d))
ans =
100 50 100
Note: This will require Signal Processing Toolbox.
per isakson
le 20 Mai 2018
I guess
- d is a row vector of whole numbers
- d consists of multiple sets of three numbers
- you search unique sets of three numbers
d = [100 50 100 100 50 100 100 50 100 100 50 100 100 50 100 100 50 100];
m = reshape( d, 3,[] );
m = permute( m, [2,1] );
unique( m, 'rows' )
returns
ans =
100 50 100
Image Analyst
le 20 Mai 2018
Try this:
d = d(1:3)
Cette question est clôturée.
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!