MATLAB: How to write function with indefinite number of outputs

functionoutput

I know how to write function of one or multiple outputs. But there are lots of function in MATLAB which can be used with one and multiple outputs also. How to handle such feature?

Best Answer

You check nargout to see how many outputs there are, and you make assignments to varargout{K} for the K'th output.