|
|
find unique row vectors of a matrix
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
|
|
|
|
Reply
|
Ioannis
|
12/14/2009 7:40:22 PM |
|
You can use functions unique() and ismember().
Write back if you can't figure it out.
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
12/14/2009 8:01:10 PM
|
|
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
|
|
|
|
Reply
|
Matt
|
12/14/2009 9:50:18 PM
|
|
> 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
|
|
|
|
Reply
|
Ioannis
|
12/14/2009 10:41:18 PM
|
|
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
|
|
|
|
Reply
|
Ioannis
|
12/15/2009 11:15:04 AM
|
|
Excuse me Matt it works!! Thank you very much!!
|
|
0
|
|
|
|
Reply
|
Ioannis
|
12/15/2009 11:21:01 AM
|
|
|
5 Replies
441 Views
(page loaded in 0.049 seconds)
|
|
|
|
|
|
|
|
|