Write a MATLAB code to compute and determine the convergence rate : Write a MATLAB code to compute and determine the convergence rate of :

(exp(h)-(1+h+1/2*h^2))/h with h=1/2, 1/2^2,..., 1/2^10

my code was:

h0=(0.5)^i;

TOL=10^(-8);

N=10;

i=1;

flag=0;

table=zeros(30,1);

table(1)=h0

while i < N

    h=(exp(h0)-(1+h0+0.5*h0^2))/h0;
    
    table (i+1)=h;

    if abs(h-h0)< TOL

        flag=1;

        break;

    end

    i=i+1;

    h0=h;
    
end

if flag==1 

    h

else

    error('failed');

end

The answer I received does not make quite any sense. Please help. 