Hi Gav,
I think you want the labsend, labreceive functionality. You can use the labindex function to switch between server behaviour and client behaviour, for instance if you use spmd with 2 labs, one being the server and one being the client you could do:
spmd
if labindex == 1
labSend(DMat, 2)
else
data = labReceive(1);
end
end
I think I should also point out that you're writing quite a bit of Java code in MATLAB, this is not necessarily the best idea. For instance, you're not closing your sockets after you read the data, you only close them in the catch block if there's an error. This is understandable because MATLAB does not have a finally statement (the equivalent functionality is provided by onCleanup).
You can call Java functions from MATLAB. In your situation it might be safer to write the code that reads from the micro-controller in Java and then call that code from MATLAB.
HTH, Tom
Best Answer