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.
function nargout_class(C,M)
% input
% C : name of the class (char) or Object
% M : name of the method (char) or method handle (function_handle)
% output
% n : number of output argument of method M (double)
Cite As
Hyeokjin Jho (2026). nargout_class (https://uk.mathworks.com/matlabcentral/fileexchange/69208-nargout_class), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Programming > Classes > Define Classes > Handle Classes >
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
