From: Marco on
I must delete two or more equal rows in a 2coloumn matrix

example :
1--2
1--2
1--3
5--8
5--8
6--7
6--7
7--8
7--8
8--9

I want this output:
1--3
8--9

I try to use unique, but it leaves one of equal rows
unique output:
1--2
1--3
5--8
6--7
7--8
8--9

thanks!
From: Matt Fig on
This seems to work:

idx = [~1 all(~diff(A),2)'];
idx = strrep(idx,[0 1],[1 1]);
A = A(~idx,:)
From: us on
"Marco " <marcodpc(a)gmail.com> wrote in message <hom8kt$6kr$1(a)fred.mathworks.com>...
> I must delete two or more equal rows in a 2coloumn matrix
>
> example :
> 1--2
> 1--2
> 1--3
> 5--8
> 5--8
> 6--7
> 6--7
> 7--8
> 7--8
> 8--9
>
> I want this output:
> 1--3
> 8--9
>
> I try to use unique, but it leaves one of equal rows
> unique output:
> 1--2
> 1--3
> 5--8
> 6--7
> 7--8
> 8--9
>
> thanks!

one of the solutions

v=[
1 2
1 2
1 3
3 5
3 5
2 4
2 4
1 2
8 9
];
[vu,vx,vx]=unique(v,'rows');
vn=histc(vx,1:max(vx));
r=vu(vn==1,:);
disp(r);
%{
1 3
8 9
%}

us
From: Marco on
ok, If I use sortrows, it works both solution, than thanks a lot.

I have another problem :
I need to delete also equal rows in reverse order:

example :
1--2
1--2
1--3--------
2--3
2--5
3--1--------
5--8--------
5--8--------
6--7
6--7
6--8
7--8
7--8
8--5--------
8--7
8--9

I want this output:
2--3
2--5
6--8
8--9
From: Marco on
I have solved my last problem with e sort 'ascend'

thanks!