currently I am studying Numerical Methods in Matlab and I need a Matlab code which would calculate Richardson Extrapolation using data given in a table, respectively for x and f(x).
For example: Use the table below to calculate f'(0) as accurately as possible.

Our professor suggested to use the find function in Matlab, as I did, but so far I only get an empty matrix as a result..
function G = richEx(x,y,xp)
h=x(2)-x(1);
h2=h;
h1=h2*2;
g1 = (-3 * ( find(y==(xp))) + 4 * (find(y==(xp + h1))) - (find(y==(xp) + 2*h1)))) / 2*h1;
g2 = (-3 * (find(y==(xp))) + 4 * (find(y==(xp + h2))) - (find(y==(xp + 2*h2)))) / 2 * h2;
G=(4*g2-g1)/3;
Can someone help me? Thank you.
Your
findmethod is returning empty matrices because it's looking for values ofyequal to some condition.For instance,
find(y == xp)looks for values ofyequal toxpand it returns the index. You haven't told us whatxpis, but chances are, there aren't any values ofythat equalxp.Furthermore, find returns the index of the value. So
find([4 5 6]==4)returns1.I would re-visit the Richardson extrapolation algorithm, because your code does not reflect what the algorithm does.