Source: https://blanchard.ep.wisc.edu/PublicMatlab/Functions/Functions.pdf