Suppose I have some function foo(not written by me) that returns multiple values, for example:
function [one, two, three, four] = foo()
one = 2;
two = 4;
three = 8;
four = 16;
end
(NB: the above is just an example, in general, I do not control the function foo.)
Also, suppose I'm in the middle of a MATLAB debugging session.
If you evaluate now foo, only the first of the returned values ββis displayed:
K>> foo()
ans =
2
If I try to capture all the values ββusing an assignment expression, I get one error; eg:
K>> all_returned_values = foo()
Attempt to add "all_returned_values" to a static workspace.
See Variables in Nested and Anonymous Functions.
K>> [v1 v2 v3 v4] = foo()
Attempt to add "v1" to a static workspace.
See Variables in Nested and Anonymous Functions.
K>> {v1 v2 v3 v4} = foo()
{v1 v2 v3 v4} = foo()
β
Error: The expression to the left of the equals sign is not a valid target for an assignment.
Is there a way to force MATLAB to return all function values ββthat are independent of assignment?
NB: , foo. ( , , MATLAB.)