How does MATLAB handle file change while the file is being executed?
Asked Answered
U

2

6

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?

Upstream answered 11/2, 2012 at 20:40 Comment(0)
E
6

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.

Elkeelkhound answered 11/2, 2012 at 21:11 Comment(1)
I'm using SGE's qsub to submit my MATLAB jobs. So basically I'm running different instances of MATLAB for each job. I should be fine.Upstream
E
3

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

Editorialize answered 25/1, 2014 at 0:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.