Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

matlab

qsub

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?

like image 543
Mohammad Moghimi Avatar asked Feb 11 '12 20:02

Mohammad Moghimi


People also ask

Can I edit a Matlab code while it is running?

You can (externally) modify the . m code for a function while the function is running. The change will not be noticed until at least a "clear" is done against the function name, or a "clear all" is done, or a "rehash".


2 Answers

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.

like image 95
eternaln00b Avatar answered Oct 17 '22 06:10

eternaln00b


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

like image 3
Khoa Avatar answered Oct 17 '22 08:10

Khoa