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
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
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
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 Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!