Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how delete repeated rows?

Subject: how delete repeated rows?

From: konrad

Date: 6 Jul, 2010 15:20:19

Message: 1 of 4

Hi!

I want do delete this rows where values are repeat.
e.g.

A=[
1,2
2,3
2,3
2,3
4,5
4,5
6,7
]

exit should be:

A=[
1,2
2,3
4,5
6,7
]

i've read sth about "unique" but i dont know excatly how to use it

Subject: how delete repeated rows?

From: Steven Lord

Date: 6 Jul, 2010 15:28:12

Message: 2 of 4


"konrad " <qnrad@wp.pl> wrote in message
news:i0vhjj$i0d$1@fred.mathworks.com...
> Hi!
>
> I want do delete this rows where values are repeat.

*snip*

> i've read sth about "unique" but i dont know excatly how to use it

Then now would seem to be a perfect time to learn how to use UNIQUE. Type
one or both of the following at the MATLAB prompt and read the descriptions,
then try using the function yourself.

help unique
doc unique

If you still can't achieve your goal, show the group what you've tried and
someone should be able to help you.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: how delete repeated rows?

From: Andy

Date: 6 Jul, 2010 15:29:04

Message: 3 of 4

% one solution

A=[
1,2
2,3
2,3
2,3
4,5
4,5
6,7
];

B=unique(A,'rows');

% Also:

doc unique

Subject: how delete repeated rows?

From: Roger Stafford

Date: 6 Jul, 2010 18:29:05

Message: 4 of 4

"konrad " <qnrad@wp.pl> wrote in message <i0vhjj$i0d$1@fred.mathworks.com>...
> Hi!
>
> I want do delete this rows where values are repeat.
> e.g.
>
> A=[
> 1,2
> 2,3
> 2,3
> 2,3
> 4,5
> 4,5
> 6,7
> ]
>
> exit should be:
>
> A=[
> 1,2
> 2,3
> 4,5
> 6,7
> ]
>
> i've read sth about "unique" but i dont know excatly how to use it
- - - - - - - - -
  There are some questions that might be asked here about what you want. In your example you showed only consecutive repeats. Are those the only ones to be deleted? Using unique will remove all duplications. Are you satisfied with the sorted order produced by unique or would you like to restore the remaining rows to their original sequencing? If the latter, then when a row appears in duplicate which copy would you like removed? It would make a difference in the ordering.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us