Source: https://www.math.drexel.edu/~mcatral/Math290sp06/matlab_proj2.pdf