This are simple script to make Matlab communicate with unity
You can find the video tutorial at this link
IMPORTANT 1: in the public class ***** : MonoBehaviour
Instead of the ***** write the name of the c sharp file. Check the name associated to the object you cerated in unity and wirte that. In my case it was Cylinder.
IMPORTANT 2: when you created the c sharp file in unity, you first press play in unity and then run the matlab code, otherwise it will not work.
If you are interested only in the c sharp code that makes matlab and unity communicate, you can find it in the "C_Sharp_Communication_Only" file.