Here is an example of how you can loop a Taylor series using a while loop in Matlab:
main.m478 chars15 lines
In this example, we compute the Taylor series of sin(x) up to a certain tolerance (1e-6 in this case) using a while loop. The loop continues indefinitely until the nth term becomes smaller than the tolerance, at which point we exit the loop and display the sum of the first n terms as the approximation of sin(x).
gistlibby LogSnag