Asked by Connor
on 23 Apr 2013

I am looking for a way to delete repeated rows without using the unique function. For example if I have the matrix

A=[2 4 8; 8 2 4; 3 3 -6]

one of the first two rows needs to be deleted. Order doesn't need to be kept. I'm sure I need to use sort, and maybe find or diff. I'm not exactly sure how to go about it.

Any and all help is appreciated!

*No products are associated with this question.*

Answer by Matt J
on 23 Apr 2013

Edited by Matt J
on 23 Apr 2013

Hint:

>> sortrows(sort(A,2))

ans =

-6 3 3 2 4 8 2 4 8

You should now find diff() rather helpful.

Connor
on 23 Apr 2013

Cedric Wannaz
on 23 Apr 2013

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 4 Comments

## Kye Taylor (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73271#comment_145088

Why don't you want to use the unique function? It's second output is gonna be real helpful.

## the cyclist (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73271#comment_145093

Guessing this is homework. That's the usual motivator for

notwanting to use particular functions.## Matt Kindig (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73271#comment_145101

It's strange that you consider the first two rows of A to be "repeated", since the order of the elements is different (one is a permutation of the other). Is this what you want?

## Connor (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73271#comment_145124

They are considered repeated because order isn't important here. This is a very small part for my project, and isn't required. My professor said if we could do this we could get some extra credit. Thanks!