Default argument expression with multiple outputs
显示 更早的评论
How do I get the correct output into the default argument if a function used in an expression has more than one output? E.g.
arguments
opts.input2 (1,1) double = function_with_multiple_outputs(function_inputs)
end
Where [output1, output2, etc] = function_with_multiple_outputs(function_inputs) and function_inputs are constants or previously defined arguments. I only want, e.g. opts.input2 to be output2 from function_with_multiple_outputs.
采纳的回答
更多回答(2 个)
Walter Roberson
2023-8-22
In MATLAB, there is no (useful) way to assign multiple outputs of a function to a single location, and there is no (useful) way to select a particular output from a command .
What would be legal generally in MATLAB (but not necessarily in an argument block) is
[opts.input2, opts.input2] = function_with_two_outputs();
This would assign the first output to opts.input2 and then assign the second output on top of opts.input2 .
1 个评论
Stephen23
2023-8-22
"This would assign the first output to opts.input2 and then assign the second output on top of opts.input2 ."
Only if OPTS is scalar (or is implicitly created by that allocation).
类别
在 帮助中心 和 File Exchange 中查找有关 Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!