Short question: Functions with multiple outputs
1 次查看(过去 30 天)
显示 更早的评论
Hi
I have seen two formalism for functions with more then one output:
function [output1, output2] = functionname(input)
or the same with the outputs not being separated by a coma:
function [output1 output2] = functionname(input)
what's the difference?
Thanks
0 个评论
采纳的回答
EristoffAbhi
2013-1-11
There is no Difference, as both the syntax are correct.First nomenclature is preferred as it is easy to understand. And if you have notice that while creating a vector e.g. a=[1 2 3]
a =
1 2 3
>> a=[1 ,2, 3]
a =
1 2 3
both are same. Similarly in the above function output syntax, the return value of your function is getting store in output1, output2. and so both the syntax are same and have same impact on your code.
0 个评论
更多回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!