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:
find unique row vectors of a matrix

Subject: find unique row vectors of a matrix

From: Ioannis Mitsos

Date: 14 Dec, 2009 19:40:22

Message: 1 of 6

Hello,

Lets say that I have a matrix:

N=[ 1 2 3 4 5
      2 3 4 5 6
      1 2 3 4 5
      0 0 0 1 0
      1 1 1 3 4]

and I want to create a matrix [A] which will have only unique row vectors of N (exclude duplicate vectors).

e.g. A=[2 3 4 5 6
                          0 0 0 1 0
                          1 1 1 3 4]

Is there a function that does this operation?I know that there is one to find unique elements from a matrix but I haven't found the way to do it in order to find row vectors of a matrix.

thanks.

Subject: find unique row vectors of a matrix

From: ImageAnalyst

Date: 14 Dec, 2009 20:01:10

Message: 2 of 6

You can use functions unique() and ismember().
Write back if you can't figure it out.

Subject: find unique row vectors of a matrix

From: Matt J

Date: 14 Dec, 2009 21:50:18

Message: 3 of 6

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <33f52213-f911-4d72-9df0-d80af6754c7a@j4g2000yqe.googlegroups.com>...
> You can use functions unique() and ismember().
> Write back if you can't figure it out.

Hmmm. I had to use histc() as well.

NN=N;
[q,i,j]=unique(NN,'rows');
[h,b]=histc(j,.5:size(NN,1)-.5);
idx=ismember(j,find(h>1));
NN(idx,:)=[],

Subject: find unique row vectors of a matrix

From: Ioannis Mitsos

Date: 14 Dec, 2009 22:41:18

Message: 4 of 6


> Hmmm. I had to use histc() as well.
>
> NN=N;
> [q,i,j]=unique(NN,'rows');
> [h,b]=histc(j,.5:size(NN,1)-.5);
> idx=ismember(j,find(h>1));
> NN(idx,:)=[],


Thank you very much Matt I will give it a try and I'll come back to you!I hope it works!!

Subject: find unique row vectors of a matrix

From: Ioannis Mitsos

Date: 15 Dec, 2009 11:15:04

Message: 5 of 6

Thanks a lot Matt for your help the above code returns the unique vectors of a matrix. However, it does not return a matrix without the unique vectors to be included.
Do you know any tools that may do that?

Subject: find unique row vectors of a matrix

From: Ioannis Mitsos

Date: 15 Dec, 2009 11:21:01

Message: 6 of 6

Excuse me Matt it works!! Thank you very much!!

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