title: How to pass a function as argument in Matlab
body: <p>I have this function defined in a m-file:</p>
  
  <pre><code>function[it,xvect,xdif,fx]=bisez(a,b,nmax,toll,fun)
  it=-1;
  xvect=[];
  xdif=[];
  fx=[];
  err=toll+1;
  
  while(it&lt;nmax &amp;&amp; err&gt;toll)
  x=(b+a)/2;
    if(fun(x)==0)
      err=0;
    else
      err=abs(b-a)/2;
    end
  it=it+1;
  xvect=[xvect;x];
  xdif=[xdif;err];
  fx=[fx:fun(x)];
    if(fun(x)*fun(a)&gt;0)
      a=x;
    else
      b=x;
    end;
  end;
  if(it&lt;nmax)
    fprintf('Convergence computed at step k:%d\n',it);
  else
    fprinf('Iteration limit reached: %d\n',it);
  end
    fprintf('Computed root: %-12.8f\n',xvect(it+1));
  return
  </code></pre>
  
  <p>Then if I try to invoke it with these commands:</p>
  
  <pre><code>fun=@(x)exp(x);
  a=1;
  b=1.5;
  nmax=1000;
  toll=2;
  bisez(a,b,nmax,toll,fun)
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>??? Undefined function or method 'bisez' for input arguments of type 'function_handle'.
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>PS: I'm using <code>Matlab 2007b</code></p>