
Originally Posted by
analysismath
Dear all,
I have a question on Matlab: when I define a new function in Matlab, I want to use another function defined by myself previously as an input argument, how can I do that?
To be more specific, suppose I have defined a function, say f(x). Now I am going to define a new function g(x)=f(x)+x and using f(x) as one of the input argument in my definition of g(x).
Is there anybody who can help me on this? Thanks a lot in advance.
Define the second function as:
Code:
function rv=g(ff,x)
rv=ff(x)+x;
Then call with:
In the calling code @f is the function handle for the function f.
CB