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

 
 

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

Submitted by:  None
Submitted on:  Mon 12 Sep 2016 06:39:44 PM UTC  
 
Category:  Interpreter Severity:  1 - Wish
Priority:  1 - Later Item Group:  Feature Request
Status:  Postponed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  dev
Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project Administrator
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>
Project 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>
Project Administrator
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 rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    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.5