Send one Matlab variable output and use it as an input for in my UR

Hello. I am currently working with a Universal Robot using the PolyScope user interface. I need this robot to communicate with my Matlab code which does image processing and then classifies the image to either category A, B or C. I have created a variable on the Matlab code called “imageSignal” which returns either 1, 2 or 3 depending on the category. What I need is to send this variable to the robot in order for it to know what to do in case imageSignal =1, 2 or 3.

I have read about RTDE and using TCP/IP communication but I do not know how to do it with Matlab or where to start.

Could any of you help me?

Maybe take a look at Modbus communication? I’ve had really good success with this on the UR robot in the past. You should be able to just write this variable to one of the general purpose integer registers on the UR (signal list here: https://s3-eu-west-1.amazonaws.com/ur-support-site/16377/ModBus%20server%20data.pdf)

Specifically, writing to register 128 should make your value easily accessible on the UR side by looking at modbus gp register 0.
Looks like this MATLAB command might do the trick:

Then you just have to setup a quick Modbus server on the teach pendant, which takes about 3 seconds. Just assign it an IP address that’s on the same subnet as whatever your matlab machine is on.