octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #61765] matlab compatibility - issorted with c


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #61765] matlab compatibility - issorted with char arrays
Date: Wed, 5 Jan 2022 12:07:48 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?61765>

                 Summary: matlab compatibility - issorted with char arrays
                 Project: GNU Octave
            Submitted by: nrjank
            Submitted on: Wed 05 Jan 2022 12:07:46 PM EST
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Nicohlas Jankowski
        Originator Email: 
             Open/Closed: Open
                 Release: 7.0.90
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

This appears to be a compatibility concern, not sure if this is from a change
in matlab behavior:

Matlab 2021b:

abc = ['a1'; 'a2'; 'a3'];

issorted (abc)
ans =
  logical
   1

issorted({abc})
ans =
  logical
   1

abc = ['a1'; 'a3'; 'a2'];

issorted (abc)
ans =
  logical
   0

issorted({abc})
ans =
  logical
   1

abc = ['a1'; 'b2'; 'a3'];

issorted (abc)
ans =
  logical
   0

issorted({abc})
ans =
  logical
   1


I included cellstrings because it seemed to be the only way octave would try
to process it:
Octave 7.0.1 (hg id: d00ae0ad8f89)

abc = ['a1'; 'a2'; 'a3'];

issorted(abc)
error: issorted: needs a vector

issorted({abc})
warning: multi-row character matrix converted to a string, only
the first row is used
ans = 1

abc = ['a1'; 'a3'; 'a2'];

issorted(abc)
error: issorted: needs a vector

issorted({abc})
warning: multi-row character matrix converted to a string, only
the first row is used
ans = 1

abc = ['a1'; 'b2'; 'a3'];

issorted(abc)
error: issorted: needs a vector

issorted({abc})
warning: multi-row character matrix converted to a string, only
the first row is used
ans = 1



So matlab appears to have no issues checking sorting on a char array, while
octave does.  Matlab also appears to look at a char array in a cell as a
single unit for sorting, whereas octave sees it as a string array, but then
aborts checking for sorting anyway.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61765>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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