[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setdiff: Octave <-> Matlab
From: |
Henry F. Mollet |
Subject: |
Re: setdiff: Octave <-> Matlab |
Date: |
Tue, 14 Jun 2005 19:06:41 -0700 |
User-agent: |
Microsoft-Entourage/10.1.1.2418 |
I doubt that setdiff(A,B) can detect similarity between 2 matrices. It
simply checks matrix elements in A and B.
Presumably, the 'rows' option would produce
ans =
1
1
1
in the *example below*. However, my octave-forge setdiff.m must be an old
version and cannot handle the 'row' argument.
Henry
A =
1 1 1
1 1 1
1 1 1
octave:30> B
B =
2 2 2
2 2 2
2 2 2
octave:31> setdiff(A,B)
ans = 1 % 1 in matrix A does not appear in matrix B
octave:32> setdiff(A,B,'rows')
usage: setdiff(a,b)
error: evaluating if command near line 28, column 3
error: called from `setdiff' in file
`/Users/mollet/Desktop/usr/local/share/octave/2.1.55/site/m/octave-forge/set
/setdiff.m'
Another example:
octave:32> A= [1 2 3;4 5 6;7 8 9]
A =
1 2 3
4 5 6
7 8 9
octave:33> B=A+10
B =
11 12 13
14 15 16
17 18 19
octave:34> setdiff(A,B)
ans =
1
2
3
4
5
6
7
8
9
octave:35> setdiff(A,B,'rows')
usage: setdiff(a,b)
error: evaluating if command near line 28, column 3
error: called from `setdiff' in file
`/Users/mollet/Desktop/usr/local/share/octave/2.1.55/site/m/octave-forge/set
/setdiff.m'
octave:35>
on 6/14/05 5:54 PM, Louis Ciotti at address@hidden wrote:
> Mike Miller wrote:
>
>> On Tue, 14 Jun 2005, John W. Eaton wrote:
>>
>>> On 14-Jun-2005, address@hidden wrote:
>>>
>>> | I am tying to use the setdiff command in octave. I am trying to get a
>>> | script that works in Matlab to work in octave. In matlab the syntax
>>> | is:
>>> |
>>> | 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.
>>> |
>>> | in octave the syntax is similar, but it does not take the rows
>>> | option. Not knowing exactly how Matlab works(I do not have a working
>>> | copy) I do not know how to get they same output in octave. Can
>>> | someone help who has a copy of Matlab??
>>>
>>> Why should that be necessary? If you want to implement something for
>>> Octave, then you must not refer to Matlab M-files. You know what the
>>> function is supposed to do, so the task is to make an independent
>>> implementation.
>>
>>
>> I think he does not know what the function is supposed to do because
>> he doesn't understand the 'rows' argument.
>>
>> Sometimes a simple google search can help because MATLAB docs are on
>> the web:
>>
>> http://taxa.epi.umn.edu/bgnews/2003/msg00074.html
>>
>> c = setdiff(A, B) returns the values in A that are not in B. The
>> resulting vector is sorted in ascending order. In set theory terms, c
>> = A - B. A and B can be cell arrays of strings.
>>
>> 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.
>>
>> Mike
>>
> 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...
>
>
>
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------
>
-------------------------------------------------------------
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
-------------------------------------------------------------