I am new to MATLAB. Can someone please tell what should I do to get a plot of the error (here, abs (z-Z)) vs the number of iterations? Another question is, earlier I used different variables and for x-axis plot of i (using plot(i,abs(z-Z)), I used ilim([0 20]), which showed "undefined function ilim for input argument double". Does this mean I can plot only when variables are named as x and y?
z=1;for i=1:100 f=(1-z)*exp(-2*z)-3*exp(-z)+2; fprime=exp(-2*z)*(2*z-3)+3*exp(-z); Z=z; z=Z-f/fprime; if abs (Z-z)<10^(-6) break endx=i;y=abs (Z-z);plot(x,y)xlim([0 20])ylim([0 1])end
Best Answer