mardi 10 octobre 2017

How to determine if an output is being ignored with ~

In Matlab, you can ignore an output with the following syntax:

[~, ixMax] = max(foo);

I have a function, with signature

[out, out1, out2, out3] = function foo(in1, in2, in3)

out1, out2 and out3 are optional outputs, and each is only needed in very specific (unusual) circumstances. Foo is computationally expensive, and out1/out2/out3 are all even more computationally expensive, but rely on intermediate state generated by foo. I'd like to be able to avoid computing out1/out2/out3 if the caller is using a ~ to ignore them. How can I check for that in the definition of foo?





Aucun commentaire:

Enregistrer un commentaire