Azzera filtri
Azzera filtri

how i can have dimension input of a defined function like f ?

2 visualizzazioni (ultimi 30 giorni)
i have a code that input of its a handle function like f, in duration of this code i need to number of input this function for example f is: f=@(x,y)(x+y)

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 1 Lug 2015
Modificato: Azzi Abdelmalek il 1 Lug 2015
f=@(x,y)(x+y)
s=func2str(f);
a=regexp(s,'(?<=@\()[\w,]+(?=\))','match')
out=numel(cell2mat(regexp(a,'\w+')))

Più risposte (1)

Walter Roberson
Walter Roberson il 2 Lug 2015
f = @(x,y)(x+y)
out = nargin(f)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by