help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function-pointer - function as argument for functions


From: Etienne Grossmann
Subject: Re: Function-pointer - function as argument for functions
Date: Wed, 26 Apr 2000 16:45:57 GMT

  Hello,

  you can do it with :

function retval = fun10( funname )
  
  retval = feval( funname , 10 ) ;
  ## or,
  ## retval = eval(sprintf("%s(10);",funname)) ;
  ## or
  ## eval(["retval = ",funname,"(10);"]) ;

end

  Hth,

  Etienne

---------------------------------------------------------------
Hello,

is it possible for example to call a function which depending on the
argument calculates sin(x) or x**2.

What I want to have would look like:


  function retval = fun10 ( funname() )
  
    retval = funname(10);
      
  endfunction

and I'd like to call it like this:

  fun( sin() )
  => -0.544

or

  fun( sqrt() )
  => 3,16




-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]