MATLAB中 怎样让两个M文件相关联着一起运行?

一个M文件中有定义函数 function 的语句 这是不能在命令窗口里运行的对吧?
另一个M文件里有这个函数的用法 单运行一个M文件是不对的 老师让两个都运行?怎么办?不胜感激啊!!!
对不起!看得不是很懂?!

打开matlab的help窗口,找到MATLAB / User's Guide / Desktop Tools and Development Environment / Startup and Shutdown / Starting and Quitting the MATLAB Program / Association Files with MATLAB on Windows Platforms,往下翻直接找到下面这样的链接,直接点击,MATLAB会帮你自动关联。
Run utility to associate files with .fig extension with MATLAB Run utility to associate files with .m extension with MATLAB Run utility to associate files with .mat extension with MATLAB Run utility to associate files with .mdl extension with MATLAB Run utility to associate MATLAB with MEX-files Run utility to associate MATLAB with P-files Run utility to associate MATLAB with all of these file types: FIG, M, MAT, MDL, MEX, and P
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2016-08-13
你把自定义函数的M文件放在Matlab路径里,这样系统能够找到,这样就可以了追问

谢谢您的回答 可是对不起 还是不懂。。。

追答

你这样做,新建一个M文件,然后把内容复制进去,其中函数那个文件名要和函数名一致,保存在默认路径里。你再试试

追问

谢谢您!我试过了 可是有错误 A function declaration cannot appear within a script M-file.
这是怎么回事啊?谢谢!!!

本回答被提问者采纳
第2个回答  2015-09-23
调用或者运行一个,窗口打开另一个运行。
第3个回答  2019-02-01
调用或者运行一个,窗口打开另一个运行。
再看看别人怎么说的。
相似回答