On Jan 10, 2008 9:24 PM, Evan <address@hidden> wrote:
I want to define a function like the following in an oct-file
function y=fun(f)
g=@(x) 1./f(x);
y=quad(g, 0, 1);
endfunction
what should I write for the sentence "g=@(x) 1./f(x);"?
thanks in advance
I still don't know if there is any standard method to do this, but
after look through the head files of Octave, I figure out a way as
follows
octave_value_list f = feval("func2str", args(0), 1);
std::string fcn = f(0).string_value ();
std::string newfcn = "@(x) 1./( (" + fcn + ")(x))";
int status;
octave_value_list nf = eval_string (newfcn, true, status, 1);
in "parse.h"
extern OCTINTERP_API octave_value_list
eval_string (const std::string&, bool silent, int& parse_status,
int hargout);
I think "hargout" is a typo for "nargout". I wonder what is
"parse_status" for. It seems that it is always zero whether the string
is evaluated successfully or not.