657
edits
(Collect outputs) |
|||
Line 36: | Line 36: | ||
{{Code|Swap values without dummy variable|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Swap values without dummy variable|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
[b,a] = deal(a,b); | [b,a] = deal (a,b); | ||
</syntaxhighlight>}} | |||
=== Collect all output arguments of a function === | |||
If you have a function that returns several values, e.g. | |||
{{Code||<syntaxhighlight lang="octave" style="font-size:13px"> | |||
function [a b c]= myfunc () | |||
[a,b,c] = deal (1,2,3); | |||
endfunction | |||
</syntaxhighlight>}} | |||
and you want to collect them all into a single cell (similarly to Python's zip() function) you can do: | |||
{{Code|Collect multiple output arguments|<syntaxhighlight lang="octave" style="font-size:13px"> | |||
outargs = nthargout (1:3, @myfunc) | |||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
edits