I do not know about mathlab.
But I think what is important is the logic of the program.
You can study available source code, and you should be able to write your own mathlab code when you understand the login of the program.