setdiff output differs from matlab
David Bateman
David.Bateman at motorola.com
Thu Sep 18 03:36:00 CDT 2008
soren at hauberg.org wrote:
> 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
>
>
> _______________________________________________
> Bug-octave mailing list
> Bug-octave at octave.org
> https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
>
>
So if the args are both vectors, but different orientations then Matlab
converts them both to be row vectors.
D.
--
David Bateman David.Bateman at motorola.com
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
More information about the Bug-octave
mailing list