storing .m files with names equal to the function? scenario if file name is different then?
Before we begin, we must first look at the syntax for a function in MATLAB.
function y=(argument list)
commands
The code above must be written in a separate m-file! The name of the file should coincide with the name of the function, i.e. .m ?? why what if not
The function syntax is:
function y=functionname(argumentlist)
commands
the functionname and the .m filename should be the same. Why? Suppose you want to call that function from another .m file or the matlab command line, it is most logical to call it with the function name. but if you use another filename as the function name, matlab wont find the function. Instead you had to call it with the filename, which would also work, but is unlogic.
So you can say, its a matter of good style.
精彩评论