Here's an example of what I'm looking for:
>> foo = [88, 12];
>> [x, y] = foo;
I'd expect something like this afterwards:
>> x
x =
88
>> y
y =
12
But instead I get errors like:
??? Too many output arguments.
I thought deal()
might do it, but it seems to only work on cells.
>> [x, y] = deal(foo{:});
??? Cell contents reference from a non-cell array object.
How do I solve my problem? Must I constantly index by 1 and 2 if I want to deal with them separately?
You don't need
deal
at all (edit: for Matlab 7.0 or later) and, for your example, you don't needmat2cell
; you can usenum2cell
with no other arguments::If you want to use
deal
for some other reason, you can:Create a function arr2vars for convenience
You can use it then like this
There is an easier way.
Provides
Full documentation at Mathworks.