MATLAB: How to send and receive the data to lab 2 and lab 3 simultanously by using labsend labreceive in matlab

MATLABparallel computing

I using Matlab pmode start local 3 to open 3 labs, now want using *labsend* to send the result in lab 1 to lab2 and lab3 simultanously, if using below code it will send to the lab2 only.
labSend(x, p+1, 0)
My desire output will be x will pass to lab2 and 3 at the same time, anyone have ideas on this?
Same for the *labReceive*, if i using below code it will receive the data from one labs only.
x = labReceive(p-1, 0)
My desire output will lab 2 and 3 receive the x at the same time, anyone have ideas on it?

Best Answer

labSend(x, 2:numlabs, 0)
However you would more typically just use
labSend(x, 2:numlabs)
For receiving,
labReceive('any', 0)
However, you would more typically just use
labReceive()
However, if it is important that both labs receive it "at the same time", then call labBarrier after doing the labSend(), and have labs 2 and 3 call labBarrier() before doing the labReceive(). This is typically not needed unless you are accessing a shared resource such as arbitrating whose turn it is to write to a device or particular section of a file.