Source: http://mapageweb.umontreal.ca/leonelli/phy1501/matlab_1.pdf