setdiff output differs from matlab
soren at hauberg.org
soren at hauberg.org
Thu Sep 18 02:30:23 CDT 2008
Quoting "John W. Eaton" <jwe at bevo.che.wisc.edu>:
> On 9-Sep-2008, Søren Hauberg wrote:
>
> | tir, 09 09 2008 kl. 13:07 -0500, skrev Michael Ferris:
> | > In octave: x = 1:5; y = setdiff(x,x); size(y)
> | > ans =
> | >
> | > 0 0
> | >
> | > In matlab: x = 1:5; y = setdiff(x,x); size(y)
> | > ans =
> | >
> | > 1 0
> |
> | Both produce empty matrices, it's only their size that differs.
>
> Yes, but if it makes sense to do so, I think we should try to make the
> sizes the same.
I agree. I was just pointing out the subtlety of the bug.
> What does Matlab return for each fo the following,
> and does it make sense, or does it just seem like an accident of the
> implementation, when it could just as easily return [] in all cases?
In Matlab 7.6.0.324 (R2008a) I get
>> x = 1:5;
>>
>> setdiff (x, x)
ans =
Empty matrix: 1-by-0
>> setdiff (x', x)
ans =
Empty matrix: 1-by-0
>> setdiff (x, x')
ans =
Empty matrix: 1-by-0
>> setdiff (x', x')
ans =
Empty matrix: 0-by-1
Søren
More information about the Bug-octave
mailing list