In a function with multiple outputs, if one output is empty does that output still need to be calculated within the function?
Show older comments
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!
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!