You have to write the code in a way function is written. Think of what are the possible inputs you want the user can give, then process those inputs and correspondingly what output your function should return. Example would be I want to calculate sum of 2 numbers, therefore i want 2 inputs and there will be one output and corresponding logic will be inside the function.
function outputOne = functionName(inputOne,inputTwo)
outputOne = inputOne + inputTwo;
Follow the link to know more about how to write a function.