FEVAL Evaluate a Function

Section: FreeMat Functions

Usage

The feval function executes a function using its name. The syntax of feval is
  [y1,y2,...,yn] = feval(f,x1,x2,...,xm)

where f is the name of the function to evaluate, and xi are the arguments to the function, and yi are the return values.

Alternately, f can be a function handle to a function (see the section on function handles for more information).

Example

Here is an example of using feval to call the cos function indirectly.
--> feval('cos',pi/4)
ans = 
  <double>  - size: [1 1]
 0.7071067811865476  

Now, we call it through a function handle

--> c = @cos
c = 
  <function ptr array>  - size: [1 1]
 @cos    
--> feval(c,pi/4)
ans = 
  <double>  - size: [1 1]
 0.7071067811865476