1

Is there any way to send strings from one code to another while they're both running on the same machine? I'm trying to collect information using MATLAB and send a string whenever an event triggers. On Processing, I'm waiting for the string to be received before updating a GUI. I've been able to get both codes to work separately, but I'm having trouble figuring out how to actually send the information. Is it more viable to rebuild the GUI in Matlab?

KGhadiri
  • 49
  • 5

1 Answers1

2

Depending on the speed requirements of the real time communication, a low tech way of doing this is to use a common file where Matlab writes time-stamped data and Processing periodically checks the file for new data.

This is one way of doing interprocess communication between two independently running processes. Another, more reliable way, is to use some kind of socket communication (tcp or udp sockets, for example) between the two processes. But programming this might be fairly complicated if you are not fluent with both Matlab and Java.

A third way is that Matlab is actually capable of running Java code directly. So if you can call the Processing code from Matlab, then you might be able to pass the strings directly to your Processing code using Java method arguments, etc.

Kavka
  • 4,062
  • 14
  • 28
  • Seconding the vote for calling Java directly from Matlab. That gets rid of all your asynchronous read/write issues. There's even a File Exchange library specifically for doing this with Processing, though it may take some updating to work with the current Matlab and Processing versions, since it's a few years old. https://www.mathworks.com/matlabcentral/fileexchange/31817-run-processing-sketches-in-matlab – Andrew Janke Feb 16 '20 at 03:07