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

조회 수: 1 (최근 30일)
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
Geoff Hayes
Geoff Hayes 2016년 3월 13일
Erez - by different windows do you mean different instances of MATLAB? Are both instances using the same function (m file)?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 13일
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
Erez
Erez 2016년 3월 13일
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 2016년 3월 13일
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.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by