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?


Solution 1:

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.