Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

erase rows in a matrix

322 views
Skip to first unread message

blanc...@exameca.fr

unread,
Nov 27, 2012, 4:07:25 AM11/27/12
to
Hi every one.

I have a matrix such as :

a =
1 1 1
2 2 2
3 3 3
2 2 2

and i Want to obtain

b =
1 1 1
3 3 3

I want to extract rows from a matrix if those rows are equal to one of it matrix.
Is it possible.
I tried

x= 2 2 2;
b=a(a<>x,:)

but it doesn't work properly.

Any suggestions ?

Thank you for all.

Fred

bruno

unread,
Nov 30, 2012, 2:29:44 PM11/30/12
to

Hello,

this lines should do the work :

[B,k] = lex_sort(A);
ind = find(and(B(1:$-1,:)==B(2:$,:),2));
// then to get (in matrix B) the (not equal) rows in lexical order :
B([ind,ind+1],:) = [];
// or to get the not equals rows in original order (result is in A)
A(k([ind,ind+1]),:) = [];

Hth
Bruno

blanc...@exameca.fr

unread,
Dec 10, 2012, 5:22:28 AM12/10/12
to
Hi.
You can try this :

data(vectorfind(data, data3, 'r') , :)=[];


Fred

bruno

unread,
Dec 14, 2012, 2:38:57 AM12/14/12
to
On Monday, December 10, 2012 11:22:28 AM UTC+1, blanc...@exameca.fr wrote:

>
> You can try this :
>
> data(vectorfind(data, data3, 'r') , :)=[];
>

Well this solution is good if you know
which row vector you want to remove from
your matrix. But in your first post you
ask for a method which can delete the
equals rows of a matrix and this is
exactly what the piece of code I posted
do (but maybe I didn't understand what
you was looking for).

Bruno
0 new messages