COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### find unique row vectors of a matrix

• Follow

```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.
```
 0

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

```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,:)=[],
```
 0

```> 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!!
```
 0

```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?
```
 0

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

5 Replies
441 Views

Similiar Articles:

7/30/2012 5:00:50 AM