Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Niels
Posts:
6
Registered:
4/10/13


Varargout "the other way around"?
Posted:
Oct 1, 2013 4:51 AM


I am trying to write a function where the number of output arguments depends on the value of one of my input arguments. However, I cannot specify upfront what the output of my function will be in a regular way.
Basically I'm looking for a way to use varargout in the script itself instead of in my function, so that I do not have to specify my output explicitly, but where I do get all the variables that are defined in my function. Putting all the output arguments in cells is not really an option, as I really need the variables explicitly named without the need to find a string in a cell.
Is this possible? :)
Small example:
runFile.m  % define In1 and In2 [Out1,output] = SomeFunction(In1,In2) % the number of output arguments is variable % do some more things 
SomeFunction.m  function [Out1,varargout]=SomeFunction(In1,In2) Out1 = 1; switch In2 case {'A' 'B'}, % ...5 output arguments... case {'C'}, % ...8 output arguments... end end 



