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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With