nargout of builtin set
2 views (last 30 days)
Show older comments
The function set() returns either zero output (when 3 arguments are supplied), either 1 output (when 1 argument is supplied). Hence I thought nargout(@set) was negative, since a variable number of outputs is supposed to rely on the varargout mechanism. However, nargout(@set)= 1 !
I don't understand. How can Matlab supply a function with varying number of outputs that does not use varargout ? Is it a bug in nargout ?
Thank you
0 Comments
Accepted Answer
Walter Roberson
on 17 Apr 2014
Varying number of outputs do not need to rely on varargout. It is completely legal to have something like
function r = set(h, varargin)
....
tr = ....
if nargout > 0; r = tr; end
end
varargout is used for arguments that are not named in the output list; ndgrid() is an example where it does not make sense to have the function code name arguments.
More Answers (0)
See Also
Categories
Find more on Variables 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!