https://devhubby.com/thread/how-to-write-a-function-in-matlab