Find x intercept using linear interpolation
<p>I am taking a course in numerical analysis at the moment and am quite new to matlab. This is a step in a larger assignment that I have been given. </p>

<p>I have a set of values, 69 values for x and y, for a curve where I want to solve the x-intercept. I don't have the corresponding value for x=0 though. </p>

<p>My idea was to interpolate linearly between the points closest to 0 to get the coefficients for a straight line and then solve for x=0, but I can't really figure out how to do it. </p>

<p>I have found the closest values to x=0 and stored them in vectors:</p>

<pre><code>x = [0.251287 0.2555517];
y = [0.014228 -0.003326];
</code></pre>

<p>So I already know that the x-intercept is around 0.25. </p>

<p>My approach was to use interp1:</p>

<pre><code>pp = interp1(x,y,'linear','pp');
</code></pre>

<p>And then use the coefficients I get from pp to solve it. The coefficients are -4.11677 and 0.014228. If I use these values for x=0 however I get an answer that is very far off, 0.003456. </p>

<p>I get a feeling that something in my approach is all wrong. Can someone point me in the right direction?</p>