How to write a function with two kind of output modes?

15 ビュー (過去 30 日間)
Mr M.
Mr M. 2016 年 6 月 24 日
コメント済み: Mr M. 2017 年 7 月 17 日
How to write a function which can be used as y = myfunc(), or [y,z] = myfunc() ?

採用された回答

Star Strider
Star Strider 2016 年 6 月 24 日
Write the first line as:
function [y,z] = myfunc()
If you only request one output, only the first output is returned by default.
  1 件のコメント
Mr M.
Mr M. 2017 年 7 月 17 日
Sorry but you missunderstood my question. I mean two different kind of output mode. So I would like to generate different y if the sytax is: y1 = myfunc(), or [y2,z] = myfunc(). I s it possible?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by