Creating a function in matlab is easy and is just like making a function in any other programming language. First we write the 'function' keyword which means we are starting our function then we write our output parameter(variable in which we want to store our output value) in square brackets and if there is none then we leave it blank. After that we write an equal ('=') sign and then we write our function name and the input parameters in round brackets ('()'), remember our function name and input parameters as they are needed to run the function. Write down the function code and remember to write the keyword 'end' when the function is finished. Save the file and it should have the same name as your function and this is a must.