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

Jan
Jan 2018년 5월 20일
편집: Jan 2018년 5월 20일
Please take the time to explain, which operation you want. Why is the output [100, 50, 100]? It could be [100,50,100,100,50,100] also. How do the inputs look like in general?
Rika Citra
Rika Citra 2018년 5월 20일
I am sorry, d= [100 50 100 100 50 100 100 50 100 100 50 100 100 50 100 100 50 100];is an input from data reading (I already done that). The data is from the simulator machine, I don't know why the data from the machine came out like that. But, the actual value of the data is [100 50 100]. So, that's why I only need one set of [100 50 100]. I already tried with unique (d) but it does not worked.
Jan
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
Ameer Hamza 2018년 5월 20일

2 개 추천

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
per isakson 2018년 5월 20일

1 개 추천

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
Image Analyst 2018년 5월 20일

0 개 추천

Try this:
d = d(1:3)

이 질문은 마감되었습니다.

제품

질문:

2018년 5월 19일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by