I would like to pass a function to another function, but with a parameter for it to use. for example, I have written a cobweb function to plot a cobweb of an iterative series function. It takes a function as an argument. eg. cobweb(@sin, x0, [0 1.5 0 1.5], max_iter) returns a cobweb plot like below for repeated sin function.
However, I want to pass another function I've written, an iterative map
function x1 = it_map(x0, r)
x1 = r*x0*(1-x0);
however to do this using the same code, I'd need to pass this function in with its own argument (r), and I can't see anyway to do that.
Is there anyway to do this? or should I just fix the argument as r in the code, which is fiddly..
Best Answer