Matlab: Create function with another function as argument -
i need create function f
function, g
, argument (g
defined in .m
file, not inline
). in body of f
, need use feval
evaluate g
on multiple values; like:
function y = f(a,b,c,g) z=feval(g,a,b,c); y=... end
what syntax ? tried use handles, got error messages.
you can way:
define
f
in m-file:function y = f(a,b,c,g) y = feval(g,a,b,c); end
define
g
in m-file:function r = g(a,b,c) r = a+b*c; end
call
f
handleg
:>> f(1,2,3,@g) ans = 7
Comments
Post a Comment