[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setdiff: Octave <-> Matlab
From: |
Mike Miller |
Subject: |
Re: setdiff: Octave <-> Matlab |
Date: |
Tue, 14 Jun 2005 20:30:11 -0500 (CDT) |
On Tue, 14 Jun 2005, Louis Ciotti wrote:
c = setdiff(A, B, 'rows'), when A and B are matrices with the same number
of columns, returns the rows from A that are not in B.
Exactly... I do not see what the 'rows' option does. For example say I
have to similar matrices A and B with 3 columns of 150 values. With
setdiff(A,B,'rows') is the result a 3 column matrix with each column
contain the values from the rows A that were not in the rows of B???
Like I said this would be easy if I had MATLAB to check it...
I'm sorry. Rereading this I see that I sent you something you already
had! That wasn't much help. I hope the stuff below helps more. It is
from MATLAB. It looks like it does what you suggested in your question
above. Strangely though, at least in this example, the rows are returned
in the reverse order.
Mike
X=ceil(10*rand(4))
X =
10 9 9 10
3 8 5 8
7 5 7 2
5 1 8 5
Y=ceil(10*rand(4))
Y =
10 1 2 3
10 4 3 2
5 9 2 1
9 1 7 8
Y(3,:)=X(2,:)
Y =
10 1 2 3
10 4 3 2
3 8 5 8
9 1 7 8
setdiff(X,Y)
??? Error using ==> setdiff
A and B must be vectors or 'rows' must be specified.
setdiff(X,Y,'rows')
ans =
5 1 8 5
7 5 7 2
10 9 9 10
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------