Pass function which has different variable to another function
이전 댓글 표시
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
DGM
2021년 4월 4일
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
2021년 4월 4일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!