# 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
* Mandatory Fields

Comment Type & Canned Response:

## Discussion

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>
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>
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>
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>
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

## Attached Files

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

Attach Files:

Comment:

No files currently attached

## Dependencies

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 project members can vote.