开发者

storing .m files with names equal to the function? scenario if file name is different then?

开发者_Go百科

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜