Short question: Functions with multiple outputs

13 ビュー (過去 30 日間)
MiauMiau
MiauMiau 2013 年 1 月 11 日
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

採用された回答

EristoffAbhi
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.

その他の回答 (2 件)

José-Luis
José-Luis 2013 年 1 月 11 日
None

Rick Rosson
Rick Rosson 2013 年 1 月 11 日
No difference, but first approach is preferred.

カテゴリ

Help Center および File ExchangeEmbedded Coder についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by