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

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

[Octave-bug-tracker] [bug #63453] output dimension of cell2mat with empt


From: Rik
Subject: [Octave-bug-tracker] [bug #63453] output dimension of cell2mat with empty inputs
Date: Tue, 7 Feb 2023 12:31:53 -0500 (EST)

Update of bug #63453 (project octave):

                Priority:              5 - Normal => 3 - Low                

    _______________________________________________________

Follow-up Comment #2:

Is there benefit to following Matlab here?  It seems kind of weird.

Matlab results


size (cell2mat (cell (0,2))
=> [0, 0]
size (cell2mat (cell (2,0))
=> [0, 0]
size (cell2mat (cell (2,0,2))
=> [0, 0, 2]


All three are empty, but Matlab seems to have made the arbitrary choice to
zero out rows and columns, but not any higher dimensions.  Note that this
seems to apply only to cell2mat() function.  For example,


size (zeros (2,0,2))
=> [2, 0, 2]


shows that input dimensions are preserved in the empty output.  A more
complicated example is


s = cell2struct (cell(2,0,3,4), {'a'; 'b'})
size (s)
=> [0, 3, 4]
size (struct2cell (s))
=> [2, 0, 3, 4]


which shows that other functions which convert between data types (cell to
struct and struct to cell) *do* preserve empty input dimensions.

Do we want to be Matlab compatible, but inconsistent in our treatment of empty
inputs?  Or should we acknowledge that Matlab is just odd in this case and not
follow their behavior?  Maybe this is worth asking over on the Octave
Discourse site.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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