You're allowed to define a function only at the beginning of an .m file, then saving it and calling the function as fcn(x,y) at the cmd window or in a script you can get it 'working'.
Oleg
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!