Pass function which has different variable to another function
Mostra commenti meno recenti
Hi all,
I'm trying to write general function to compute Lyapunov exponents and my general function includes several functions as arguments,
L(v, fun, dfun, gs, n) --> in that function arguments fun, dfun and gs are functions
When I want to call that function if fun and dfun have same input argument with L function, there is not any problem. I can do it as,
L(v, @fun, @dfun, @gs, n)
My problem raises if fun and dfun functions have another variables except common input v. (for example, general logistic map includes r parameter in the equation of
f(x,r) =r*x*(1-x)) How can I call function L if argument functions fun and dfun includes some other parameters?
Thanks for all comments and help
2 Commenti
DGM
il 4 Apr 2021
If I get you right, you have a function that typically takes a bunch of function handles as arguments, but sometimes you need to include additional arguments to be passed to those functions when they're called internally.
If that's about right, I'm not sure my advice is good practice. You could always use varargin and configure your input parsing to handle name-value pairs for your input arguments. That way you could optionally specify an argument list for a certain function using a cell array.
Huseyin YILDIRIM
il 4 Apr 2021
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!