An explanation of the functions I have written in Matlab