Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything like deal() for normal MATLAB arrays? [duplicate]

Possible Duplicate:
How do I do multiple assignment in MATLAB?

When dealing with cell arrays, I can use the deal() function to assign cells to output variables, such as:

[a, b, c] = deal(myCell{:});

or just:

[a, b, c] = myCell{:};

I would like to do the same thing for a simple array, such as:

myArray = [1, 2, 3];
[a, b, c] = deal(myArray(:));

But this doesn't work. What's the alternative?

like image 873
jjkparker Avatar asked Apr 29 '10 20:04

jjkparker


1 Answers

One option is to convert your array to a cell array first using NUM2CELL:

myArray = [1, 2, 3];
cArray = num2cell(myArray);
[a, b, c] = cArray{:};

As you note, you don't even need to use DEAL to distribute the cell contents.

like image 50
gnovice Avatar answered Sep 28 '22 18:09

gnovice