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
fin m-file:function y = f(a,b,c,g) y = feval(g,a,b,c); enddefine
gin m-file:function r = g(a,b,c) r = a+b*c; endcall
fhandleg:>> f(1,2,3,@g) ans = 7
Comments
Post a Comment