MATLAB 如何在文件执行时处理文件更改?
假设您开始运行该脚本。当您在执行该文件时更改该文件会发生什么? MATLAB 似乎会获取该文件的副本,然后开始执行它。我想确定我是对的。也就是说,我想在集群上运行具有不同参数的 MATLAB 脚本。如果我对那个文件进行更改,它是否可以正常工作?或者我需要自己创建该文件的多个副本吗?
Assume that you start running the script. What happens when you change that file when it is being executed? It seems that MATLAB takes a copy of the file and then starts executing it. I want to make sure that I am right. That said, I want to run a MATLAB script with different parameters on a clusters. Does it work correctly if I do the changes on that one file. Or do I need to create multiple copies of the file myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在运行时更改脚本/函数的内容不会影响脚本的操作,因为 MATLAB 正在运行(一般而言)“缓存”和“预处理”版本的文件。至于在集群中运行具有多个参数的脚本,我假设您正在使用并行计算工具箱?
一种选择可能是让脚本从 MAT 文件加载其参数,从而允许您在所有工作线程上运行相同的脚本,但对不同的参数进行操作。
Changing the contents of a script / function while it is running will not affect the operation of the script as MATLAB is running a (generically speaking) "cached" and "preprocessed" version of the file. As for running a script with multiple parameters in a cluster, I assume you are using the Parallel Computing Toolbox?
One option might be to have the script load its parameters from a MAT file, allowing you to run the same script on all workers, but operate on different parameters.
基本上,如果您只有一个 Matlab m 文件来进行所有计算,那就没问题了。
但是,如果您编辑的文件在计算过程中被多次调用,那么您将面临在运行时通过编辑来调用文件的多个版本的风险。在这里查看更多信息: http://www.mathworks.com.au/matlabcentral /newsreader/view_thread/261376
Basically you will be fine if you only have one Matlab m-file for all of your computation.
But if if the file you edit get called multiple times during your computation then you will run the risk of calling multiple versions of the file by editing while running. See more in here: http://www.mathworks.com.au/matlabcentral/newsreader/view_thread/261376