nargout

Returns the number of outputs.

Syntax

R = nargout

Syntax

R = nargout(function)

Inputs

function
The function to be queried for the number of outputs. For a function that can return different numbers of outputs, the result will be the negative of the first optional ouput.
Type: string
Dimension: string

Outputs

R
The number of outputs.

Examples

In function:
function [x,y] = myfunc(a)
    x = nargout;
    y = a;
end
[a,b] = myfunc(3)
a = 2
b = 3
Defined function:
R = nargout('sin')
R = 1