# How to control an UR5 robot through MATLAB via TCP client

**URL:** <https://forum.universal-robots.com/t/how-to-control-an-ur5-robot-through-matlab-via-tcp-client/33559>\
**Category:** Robot Communication\
**Created:** [April 4, 2024, 9:44am UTC](https://forum.universal-robots.com/t/how-to-control-an-ur5-robot-through-matlab-via-tcp-client/33559 "2024-04-04T09:44:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![augusto.fantinelli](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@augusto.fantinelli](https://forum.universal-robots.com/u/augusto.fantinelli)\
**Post date:** [April 4, 2024, 9:44am UTC](https://forum.universal-robots.com/t/how-to-control-an-ur5-robot-through-matlab-via-tcp-client/33559/1 "2024-04-04T09:44:02Z")

</div>

Hello!

I want to control the UR5 CB3 robot using MATLAB by sending the URScript’s commands directly into the socket.  
For example, writing a “movej([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])” or a “get\_actual\_tcp\_pose()” in such a way that the robot listens and executes this command/returns the information, without needing a script in the robot’s memory (such as I have done previously in older robots using a serial port).

I am currently setting the communication in the following manner:

```auto
host = '10.0.26.182';
port = 30003;
s = tcpclient(host, port,'ConnectTimeout',10,'Timeout',10);
configureTerminator(s,'CR');
fopen(s);
disp('Connected!');

```

Is the real-time connection appropriate in this case, or should I be using RTDE.  
Sorry for my ignorance and thank you beforehand for your help!

---

<div class="post-metadata">

**Author:** ![augusto.fantinelli](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@augusto.fantinelli](https://forum.universal-robots.com/u/augusto.fantinelli)\
**Post date:** [April 9, 2024, 11:22am UTC](https://forum.universal-robots.com/t/how-to-control-an-ur5-robot-through-matlab-via-tcp-client/33559/2 "2024-04-09T11:22:18Z")

</div>

Some other updates:

- I am using my university’s local network, so both the computer and the robot are assigned DHCP;
- I can ping the robot and receive its returning messages;
- Using Wireshark I managed to see that the messages are correctly sent from MATLAB in the PC to the robot, but it acknowledges and does not respond:
- In the Ethernet/IP page in Polyscope the LED remains yellow, as if no scanners were connected.
