How do I make matlab display messages from each worker in the order in which they were generated

107 Views Asked by At

My application starts 2 workers which print things the screen with disp

parpool('local', 2);
spmd
    idx=labindex;

    if idx==1
        %print messages to the screen every 10 seconds.
    end

    if idx==2
        %print messages to the screen every 5 seconds. 
    end

end

The problem is that I need to wait for worker 1 to completely finish before I'm able to see the output of worker 2. Matlab separates the output of each Lab and it only displays the output of Lab 2 after it has finished displaying the output of Lab 1.

Lab 1: 
1st message from lab 1.
2nd message from lab 1.
3rd message from lab 1.
...

Lab 2: 
1st message from lab 2.
2nd message from lab 2.
3rd message from lab 2.
...

I would like see the displayed messages from each worker in the order in which they were displayed. In this case the output should look like:

Lab 1: 
1st message from lab 1.
2nd message from lab 1.
Lab 2: 
1st message from lab 2.

Lab 1: 
3rd message from lab 1.
4th message from lab 1.
Lab 2: 
2nd message from lab 2.

...

How can I achieve this? I cannot use the Interactive Parallel Command Window since I use matlab on the terminal and I must use matlab R2014a.

0

There are 0 best solutions below