octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making unique() semantics compatible with MATLAB


From: Ben Abbott
Subject: Re: Making unique() semantics compatible with MATLAB
Date: Wed, 30 Mar 2016 07:31:22 -0400

> On Mar 30, 2016, at 12:51 AM, Danny Goodman <address@hidden> wrote:
> 
> Hi Octave Developers,
> 
> A MATLAB function I tried to run just broke because the 'unique()' function 
> behaves differently between Octave and MATLAB. Specifically, consider this 
> example:
> 
> A = [9 2 9 5];
> [C1, ia1, ic1] = unique(A)
> 
> 
> MATLAB returns column vectors for ia1, ic1 but Octave returns row vectors. 
> Being new to this mailing list, I wanted to ask for advice before submitting 
> a patch to fix this. Am I right that one of the goals of the Octave project 
> is to be able to run MATLAB code as is?
> 
> Thanks,
> Danny

I can confirm the bug. With Matlab I get …

A = [9 2 9 5];
[C1, ia1, ic1] = unique(A)

C1 =

     2     5     9


ia1 =

     2
     4
     1


ic1 =

     3
     1
     3
     2

And with the default branch of the current source archive I get …

A = [9 2 9 5];
[C1, ia1, ic1] = unique(A)
C1 =

   2   5   9

ia1 =

   2   4   3

ic1 =

   3   1   3   2

Please submit a bug report and attached your patch. Btw, there look to be two 
bugs. The second is that a1 returns the indices of the last match, and Matlab 
returns the first.

Ben






reply via email to

[Prev in Thread] Current Thread [Next in Thread]