Using Matlab and Python for Ur5 rtde

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(‘’));
if count(py.sys.path,URData) == 0

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.