nargout doesn't work for methods. Although some workaround was proposed(https://kr.mathworks.com/matlabcentral/answers/96617-how-can-i-use-nargin-nargout-to-determine-the-number-of-input-output-arguments-of-an-object-method), it does not work for inherited methods. This function extends nargout function to methods and inherited methods.
% C : name of the class (char) or Object
% M : name of the method (char) or method handle (function_handle)
% n : number of output argument of method M (double)
Hyeokjin Jho (2021). nargout_class (https://www.mathworks.com/matlabcentral/fileexchange/69208-nargout_class), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!