Changing function logic parameters depending on outputs

1 回表示 (過去 30 日間)
David H
David H 2015 年 2 月 18 日
コメント済み: David H 2015 年 2 月 18 日
If I have a function with 3 output arguments
[a,b,c] = fun(x)
I want the function only to calculate a,b,c if I actually call for them i.e. if I only want "c" I want to be able to call
[~,~,c] = fun(x)
without fun calculating a and b
what logical function can I use based on the specific outputs requested to achieve this? Probably a fairly trivial question but I can't find the answer.

採用された回答

Thorsten
Thorsten 2015 年 2 月 18 日
編集済み: Thorsten 2015 年 2 月 18 日
You can use the istilde from http://biorobots.cwru.edu/personnel/adh/stackoverflow/04/ with the caveat that it works just in functions or scripts, but not from the command line, as described in http://stackoverflow.com/questions/19498911/how-to-determine-if-an-output-of-a-function-call-is-unused-matlab
  1 件のコメント
David H
David H 2015 年 2 月 18 日
Thanks, that seems to do what I was looking for.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by