In MATLAB, there is a special rule for the very first function in a function file. In that one case, if the name of the file and the name of the function differ, then MATLAB will use the name of the file as the function name, and it will not be available under the name given in the function statement. This is confusing and can lead to problems, so it is recommended not to use this feature.
The implementation of functions inside of script files is much like as-if there had been a "function" statement at the beginning of the file that used the file name as the function name. This analogy is not accurate with respect to which workspace is used by the script, but it works with the scoping rules and all the debugger and help facilities that can reference a function inside a file (something that you cannot normally do from the outside). If the script name and the function name were the same that would lead to a name conflict. MATLAB detects the situation and simply refuses to permit execution, same as if you had a syntax error that it was unable to compile.
Best Answer