Scriptsvs. Functions
Program files can beScriptsthat simply execute a series of MATLAB statements,or they canbefunctionsthat also accept input arguments and produce output. Bothscripts and functions contain MATLAB code,andbothare stored in text files with a .m extension.However,functions are more flexible and more easily extensible.
说的很笼统,两者的区别就是调用方式不一样,function更灵活更容易扩展。其实传递参数不是function的专属,Script也可以接受传来的参数。下面举一个很简单的例子,更容易理解2者在使用中的区别。
在实际开发中,很多时候需要通过shellscript或者shellcommand来执行matlab函数(以c++为例,这种方法可以看作除了