title: Using nlinfit in Matlab?
body: <p>I'm having trouble understanding and applying the use of <code>nlinfit</code> function in Matlab. So, let's say I'm given vectors </p>
  
  <pre><code>x = [1, 2, 3, 4, 5] 
  y = [2.3, 2.1, 1.7, .95, .70] 
  </code></pre>
  
  <p>and I'm asked to fit this data to an exponential form (I don't know if the numbers will work, I made them up) where <code>y = A*e^(Bx) + C</code> (<code>A/B/C</code> are constants). </p>
  
  <p>My understanding is that <code>nlinfit</code> takes 4 arguments, the two vectors, a <code>modelfunction</code> which in this case should be the equation I have above, and then <code>beta0</code>, which I don't understand at all. My question is how do you implement the <code>modelfunction</code> in <code>nlinft</code>, and how do you find <code>beta0</code> (when only working with 2 vectors you want to plot/fit) and how should it be implemented? Can someone show me an example so that I can apply this function for any fit? I suspect I'll be using this a lot in the future and really want to learn it. </p>