In a function with multiple outputs, if one output is empty does that output still need to be calculated within the function?
古いコメントを表示
Say I have a function [a,b] = functionname(c), that looks something like this:
[a,b] = functionname(c)
List of steps to calculate a
List of steps to calculate b (which require a has previously been calculated).
Is there a way to ONLY calculate a? I'm aware that I can type [a,~] = functionname(c), but this will still carry out the list of steps to calculate b (which take a while). I'm looking for something like this:
[a,b] = functionname(c)
List of steps to calculate a
if b is not ~
List of steps to calculate b
end
However I just can't work out the criteria I'm looking for in the if statement.
I'm aware I could separate this into two functions, and this is the way I'll go about it if what I'm after isn't possible, but I'd like to stick to the one function if possible.
Thanks!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Argument Definitions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!