Info

This question is closed. Reopen it to edit or answer.

How to write a function to delete the duplicated arrays?

1 view (last 30 days)
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.

Answers (2)

Jos (10584)
Jos (10584) on 3 May 2014
A = [1 2 2 2 3 1 1]
tf = [true diff(A)~=0]
B = A(tf)
  2 Comments
guven baykus
guven baykus on 3 May 2014
I want to find solution as [1 2 3 1]. it is not useful.
Jan
Jan on 3 May 2014
And Jos' solution does reply [1,2,3,1]. Therefore I'm convinced, that it is useful. +1

Jan
Jan on 3 May 2014

Community Treasure Hunt

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

Start Hunting!