How do I do multiple assignment in MATLAB?
Posted
by Benjamin Oakes
on Stack Overflow
See other posts from Stack Overflow
or by Benjamin Oakes
Published on 2010-02-25T19:50:12Z
Indexed on
2010/04/30
2:17 UTC
Read the original article
Hit count: 278
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?
© Stack Overflow or respective owner