Source: https://blricrex.hypotheses.org/files/2015/03/TutoCREx_2014_Mars_Matlab.pdf