bugGNU Octave - Bugs: bug #49072, assigning double arrays to cell...

 
 

bug #49072: assigning double arrays to cell arrays: matlab incompatibility?

Submitter:  None
Submitted:  Mon 12 Sep 2016 06:39:44 PM UTC
   
 
Category:  Interpreter Severity:  1 - Wish
Priority:  1 - Later Item Group:  Feature Request
Status:  Wont Fix Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 12 Nov 2021 03:40:18 AM UTC, comment #5: 

seems there's been no interest in 5 years.  closing as Won't Fix. Can reopen if someone wants to dive into the code to figure out where to add a warning.

Nicholas Jankowski <nrjank>
Group Member
Thu 22 Sep 2016 09:15:37 PM UTC, comment #4: 

I guess that a warning could be added somewhere, without looking at any related code, lowering priority (may also be closed later as won't fix if no one reports any interest in working on this).

Mike Miller <mtmiller>
Group Member
Mon 19 Sep 2016 06:35:42 PM UTC, comment #3: 

Yes, c(1,:)={rand(1,2)} works in matlab, and assigns a 1x2 double to each individual cell.

Confusing about the assignment c(1,:) = rand(1,2) is that, by analogy to assigning to a numerical array, an unsuspecting user might expect c(1,1) and c(1,2) to contain a single double.

For that end you need c(1,:) = num2cell(rand(1,2)).

Maybe a warning would be nice to have, when assigning a double array to cell of same size

warning: assigning array of double to cell of same size. Did you mean to use num2cell?

Anonymous
Mon 12 Sep 2016 09:09:51 PM UTC, comment #2: 

Matlab probably wants the RHS of the expression in curly brackets.

Does this work in Matlab?


c = cell (2,2);
c(1,:) = {rand(1,2)}


If it does, then I would say that Octave's syntax is easier to understand and there is no reason to change it.

Rik <rik5>
Group administrator
Mon 12 Sep 2016 07:40:29 PM UTC, comment #1: 

Thanks for the bug report. This is not an incompatibility under our usual guidelines, something which works in Matlab but doesn't work in Octave would be.

I don't know whether this is an intended feature over how Matlab cell assignment works or not.

Mike Miller <mtmiller>
Group Member
Mon 12 Sep 2016 06:39:44 PM UTC, original submission:  

consider the following code:


c=cell(2,2);
c(1,:) = rand(1,2)


Matlab will report:
Conversion to cell from double is not possible.

Octave assigns the double array to each element:
c =
{
  [1,1] =

     0.64712   0.93186

  [2,1] = [](0x0)
  [1,2] =

     0.64712   0.93186

  [2,2] = [](0x0)
}

Is this intended behavior ?

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-12 nrjank StatusPostponed Wont Fix
        Open/ClosedOpen Closed
    2016-09-22 mtmiller Severity3 - Normal 1 - Wish
        Priority5 - Normal 1 - Later
        Item GroupOther Feature Request
        StatusNeed Info Postponed
    2016-09-12 mtmiller Item GroupMatlab Compatibility Other
        StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code