It appears to you that you cannot run your function because the end statement terminates it and returns to the calling program. The function runs, but since there is no code between the function statement and the end statement, nothing is done. Put the end statement at the end of your code, and delete the clear statement. It is never a good idea to put clear in your function because it clears the function workspace, including all the arguments that have been passed to it.
The Detailed explanation goes here line invites you to document your function and its use. Explain what the function does, what the input arguments are, which ones are optional, and what the outputs are. It is for your benefit, and the benefit of anyone else who might use your function. I also put a creation date and revision history.