How to write a function to delete the duplicated arrays?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hi, I have tried to write a function that finding to duplicated numbers and remove them in my array. I know the unique function is useful for such kind of problems but it is not for me. For instance,my array is [1 2 2 2 3 1]. I want to delete the consecutive numbers such [1 2 3 1]. Please help me about this.
댓글 수: 0
답변 (2개)
Jos (10584)
2014년 5월 3일
A = [1 2 2 2 3 1 1]
tf = [true diff(A)~=0]
B = A(tf)
댓글 수: 2
guven baykus
2014년 5월 3일
Jan
2014년 5월 3일
And Jos' solution does reply [1,2,3,1]. Therefore I'm convinced, that it is useful. +1
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!