I believe that the following error is generated on executing the above code :
Index exceeds matrix dimensions.
Error in taylor_demo (line 10)
f = (1/((t(k))^2)) - (20 * (y(k))) / (t(k));
This is due the variable 'y' only being defined with 2 values. Hence, when k = 3, it is unable to access the value y(3).
A good way to debug errors in code is to use the MATLAB Debugger. Using the following command will stop at the point of the error in the code, and you can then display the temporary results at the time of error.
This is useful in checking the values of the different variables. To clear the debugging conditions once you are done, the following command can be used.
There are also many other options associated with the debugger. I would recommend going over the documentation :