If I run the same script simulatneously on deifferent windows, can I get false results?

3 vues (au cours des 30 derniers jours)
If I run the same script simulatneously on deifferent windows, but with different parameter which I put in by hand, can I get false results because matlab might confuse betweeb the different runs? I should stress that I change the parameter by changing several values of variables withing the code itself, then save the fuile and run again. I'm not reading any data manually while script is running. THX!
  1 commentaire
Geoff Hayes
Geoff Hayes le 13 Mar 2016
Erez - by different windows do you mean different instances of MATLAB? Are both instances using the same function (m file)?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Mar 2016
If you have different MATLAB instances, then they can get confused if:
  • your program modifies source code while they are running
  • you write or save to the same file without taking steps to synchronize the access
  • you use the same memory-mapped file with memmapfile
  • you somehow share an object with state such as saving an open videoreader and restoring it in multiple places
  • you use shared memory segments with the same key (a pretty advanced use that requires some C/C++ code to set up the shared memory)
However, if you are just executing the same .m code and writing to different files, then the sessions will not get confused.
  2 commentaires
Erez
Erez le 13 Mar 2016
THX, can you please just clarify a bit more, what do you mean by "your program modifies source code while they are running"? What is this "source code"?
Walter Roberson
Walter Roberson le 13 Mar 2016
Source code is .m files. For example if you have
function generate_lucky(M)
fid = fopen('lucky.m', 'wt');
fprintf(fid, 'function r = lucky()\n');
fprintf(fid, 'r = randi([1 %d])\n', M);
fclose(fid);
clear lucky
Then each time generate_lucky was run, it would write a new lucky.m . If you had multiple sessions calling lucky, then the changes made to the .m code in one could confuse the running of the other session.
(Source code can also be .mex* files or any other programming language, if you are calling the code from inside MATLAB. For example if you rewrote a Java .jar from inside one session and were calling it from your code, the other session might get confused.)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Geology dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by