How can I remove a duplicate set values?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
Rika Citra
2018년 5월 20일
Jan
2018년 5월 20일
Do you know the length of the sequence or does the determination of the period belongs to the problem?
답변 (3개)
Ameer Hamza
2018년 5월 20일
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.
댓글 수: 0
per isakson
2018년 5월 20일
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
댓글 수: 0
이 질문은 마감되었습니다.
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!