Example

This example introduces us to the world of MATLAB/octave when dealing with functions (and "handles"):

Our first, very simple, program is just our function, f:

function a=f(b)
a = b*100;
return %a
end

At this point we could evaluate it at some value by using the feval function:

octave:1> feval('f',2)
ans = 200

But what we really want is to pass this to our "bigger" program that will do more operations (like program two here):

function [low,high] = sim(ff,l,u)
low=feval(ff,l);
high=feval(ff,u);
return %return the upper and lower bound [low,high]
end

Which we run using the "handle" mechanism like above (for function f or ANY function):

octave:1> [ll,hh]=sim('f',2,5)
ll = 200
hh = 500
octave:2> [ll,hh]=sim(@f,2,5)
ll = 200
hh = 500
octave:3> [ll,hh]=sim('cos',2,5)
ll = -0.41615
hh = 0.28366
octave:1> [ll,hh]=sim('cos',0,pi)
ll = 1
hh = -1