# Using Matlab and Python for Ur5 rtde

**URL:** <https://forum.universal-robots.com/t/using-matlab-and-python-for-ur5-rtde/21182>\
**Category:** Robot Communication\
**Created:** [May 10, 2022, 9:03am UTC](https://forum.universal-robots.com/t/using-matlab-and-python-for-ur5-rtde/21182 "2022-05-10T09:03:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon66505122](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@anon66505122](https://forum.universal-robots.com/u/anon66505122)\
**Post date:** [May 10, 2022, 9:03am UTC](https://forum.universal-robots.com/t/using-matlab-and-python-for-ur5-rtde/21182/1 "2022-05-10T09:03:23Z")

</div>

Hello,  
I am a student and new to UR and I just started to code my rtde control for my Cobot. I used the python code provided by UR and I am now able to do simple movements. The goal of this project is to move the cobot to objects via image processing. I wrote the image processing and the controller in matlab / simulink.  
Now here is where my issues start. After a lot of trying I am not able to connect my python script (which runs the rtde connection to my robot) to my simulink.  
I can read data from the python in matlab with:

URData = fileparts(which(‘main.py’));  
if count(py.sys.path,URData) == 0  
insert(py.sys.path,int32(0),URData);  
end

pyOUT = py.main.UR5(a1)

A1 = pyOUT{1}{1}  
A2 = pyOUT{1}{2}  
A3 = pyOUT{1}{3}  
A4 = pyOUT{1}{4}  
A5 = pyOUT{1}{5}  
A6 = pyOUT{1}{6}

I am not comfortable with python but used it because the code was provided by UR. I can’t send my matlab output to the python script. Maybe I am making this more complicated than it has to be but like I said I am new to this. Is there maybe a way to do the rtde directly in matlab without python scripts? If yes please let me know.

Thanks in advance for your help.
