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:
remove repeated rows

Subject: remove repeated rows

From: ratnesh kumar

Date: 21 May, 2010 10:33:04

Message: 1 of 2

hi ,
i have to remove rows those have repeated with same elements in the matrix.
suppose
v =[1 1 11
     1 2 10 % (1)
     1 3 9
     1 4 8
     1 5 7
     1 6 6
     2 1 10 % here is repeatition (1) with same elements
     2 2 9
     2 3 8
     2 4 7
     2 5 6
     3 1 9
     3 2 8
     3 3 7
     3 4 6
     3 5 5
     4 1 8
     4 2 7
     4 3 6
     4 4 5
     5 1 7
     5 2 6]
similarly some others are also repeating
final matrix is like
V=[1 1 11
1 2 10
1 3 9
1 4 8
1 5 7
1 6 6
2 2 9
2 3 8
2 4 7
2 5 6
3 3 7
3 4 6
3 5 5
4 4 5]
how it is possible iam trying unique but not getting the desired results.

Subject: remove repeated rows

From: Sean

Date: 21 May, 2010 12:30:25

Message: 2 of 2

"ratnesh kumar" <iam_ratnesh@yahoo.co.in> wrote in message <ht5nh0$mou$1@fred.mathworks.com>...
> hi ,
> i have to remove rows those have repeated with same elements in the matrix.
> suppose
> v =[1 1 11
> 1 2 10 % (1)
> 1 3 9
> 1 4 8
> 1 5 7
> 1 6 6
> 2 1 10 % here is repeatition (1) with same elements
> 2 2 9
> 2 3 8
> 2 4 7
> 2 5 6
> 3 1 9
> 3 2 8
> 3 3 7
> 3 4 6
> 3 5 5
> 4 1 8
> 4 2 7
> 4 3 6
> 4 4 5
> 5 1 7
> 5 2 6]
> similarly some others are also repeating
> final matrix is like
> V=[1 1 11
> 1 2 10
> 1 3 9
> 1 4 8
> 1 5 7
> 1 6 6
> 2 2 9
> 2 3 8
> 2 4 7
> 2 5 6
> 3 3 7
> 3 4 6
> 3 5 5
> 4 4 5]
> how it is possible iam trying unique but not getting the indesired results.


Try this:
>>uniqueV = unique(sort(V')','rows');

Algorithm:
-transpose and sort so the members of each column are the same order
-transpose again so the sorted columns are once again rows
-unique() rows

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