title: fixed point iteration in matlab
body: <p>So I am meant to write a Matlab function that has a starting guess p and tolerance e as inputs and outputs the number of iterations n and final fixed point approx pn satisfying abs(pn-pn-1) &lt;= e for a given function g. Here is what I currently have:</p>
  
  <pre><code>function f = fixed(p,e)
  i=1;
  pn=g(p);
  while (abs(pn - p) &lt;= e)
      pn = g(p)
      i=i+1;
      p=pn
  end
  end
  </code></pre>
  
  <p>But I'm not sure where I'm going wrong. Do I need to include another if statement in the case that the absolute difference is >e? What else would I include in such a statement?</p>