This time I formatted your code for you , but in future please do it yourself by selecting the code text and clicking the {} Code button that you will find above the textbox.
It would help us if you use consistent leading whitespace (four spaces per tab) and please do not include blank lines in your code.
Now to your problem: yre you getting and error message? If so, what exactly? How are you calling the function? Is the folder where the function is saved on your MATLAB path?