I want to use two MATLAB sessions on the same machine to run two different programs. My problem is that at some stage, the first program must use some results of the second program. So, is there a function that may apply to the first program to expect a step up the appearance of a result.
1 Answer
The easiest way to solve this is to have process #1 create a file in a place accessible by both process #1 and process #2. Process #1 runs until it gets to the point where it needs the results from process #2. At this point, it goes into a loop while exist(myFileName),pause(1),end, which makes it wait as long as the file exists, checking every second for whether the file's gone. Process #2 removes the file as soon as it's done writing out the results, at which point process #1 continues.
4 Comments
Amro
perhaps you should put a
pause(..) in that loop :)Jonas
@Amro: Yes, I guess I should. Thanks!
bzak
if I have in process # 1: runmyfile1.m; runmyfile2.m; and in process # 2: runmyfile3.m; runmyfile4.m; I want the execution of runmyfile4.m occurs after the onset of the outcome of runmyfile1.m noted runmyfile1.mat
Jonas
@bzak: In this case,
runmyfile1.m should write a file wait.plz right when it's launched. The file wait.plz is deleted by runmyfile1.m as soon as the output runmyfile1.mat has been written. The while-loop in my answer would be executed as the first line of runmyfile4.m.