Number of input parameters of a function.

1 Ansicht (letzte 30 Tage)
Milad Omidi
Milad Omidi am 5 Apr. 2019
Kommentiert: John D'Errico am 5 Apr. 2019
If you have a function's handle,
Is there any way to figure out how many input parameters it expects in the function's signature?
Even ugly hacky ways are fine.
-Milad

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 5 Apr. 2019
nargin(FunctionHandle)
  1 Kommentar
John D'Errico
John D'Errico am 5 Apr. 2019
A good way to learn this would have worked is to use methods. For example:
H = @(x,y) x+y
H =
function_handle with value:
@(x,y)x+y
>> methods(H)
Methods for class function_handle:
display func2str functions nargin nargout

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by