Hi! I am new to MATLAB and I am using this code
x0=-1.2;
maxIter=10;
tolX=0.001;
x=x0;
xold=x0;
for i=1:maxIter
f=(x+1)*(x-1/2);
df=2*x+1/2;
x=x-f/df
err=abs(x-xold);
xold=x;
if (err<tolX)
break;
end
end
to try and plot logarithms of the errors against each other. My though process is to write
>> prevErr=err(1:9);
>> currErr=err(2:10);
>> plot (log(prevErr),log(currErr),'--r')
but after the first line I am getting the notice "Index exceeds the number of array elements (1)." if anyone know how I can fix this please let me know!