Ok first of all you need to understand some basics about how to write the functions ..... So what you do post both of you code and mention which program you want to call in another program with some description..... I will modify the code and post it across... Generally way it is written is matlab using following steps-
1) one need to have both function and it's caller in same folder
2) one need to set the path of matlab command execution to that folder.
3) the function name and file name for that function need to be same in matlab.
Good luck