Can I run the same script (and subfunctions) from two diffent matlab windows?

13 Ansichten (letzte 30 Tage)
I have a script that calls subfunctions. I am wondering if I'll run into any problems when I call the script and hence the subfunctions from two different matlabs. The background is that I am running an optimization. I want to optimize two different sets of data independently meaning calling the optimization script from to different matlabs. Will I have problems when the script calls the subfunction which is executing the simulation? For example that input/output parameters will get messed up this way among the different matlabs. Or is matlab using some temporary versions of all called scripts and functions per workspace/matlab window?
I'd really appreciate any answers/hints/help on this.
Thanks!

Antworten (1)

Guillaume
Guillaume am 4 Dez. 2015
Bearbeitet: Guillaume am 4 Dez. 2015
Scripts and functions are simply text files. They are not executables. So, yes They can be run without any issue(*) from as many matlab sessions as you want. Each matlab session will read the script/functions, and execute them in their own workspace.
*: unless of course, your script writes data to a fixed file, in which case both instances would overwrite each other data.
  2 Kommentare
Walter Roberson
Walter Roberson am 4 Dez. 2015
Also if the function overwrites the .m files themselves then you will have problems.
Matt Cooper
Matt Cooper am 7 Okt. 2022
As of R2021b (possibly R2021a), if the calling script is edited in the second instance, the first instance will recognize those changes and apply them while the script is still running in the first instance (in my experience). In other words, the parallel execution hack of opening multiple instances and running the same script over different sets of inputs is more complicated now (you can still do it if you save multiple copies of the calling script). Better to learn how to use the parallel pool (and background pool) functionality.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by