- Home /
MATLAB with Unity
Is there anyway to link matlab directly into unity? I have external sensors, that are then run through data collection and amplification, processed by matlab and output information that I would like to be received in real time by unity to control elements in the 3d environment. Is this possible?
i don't know exactly but i have an idea u can make your matlab to write your information in a txt file then make your c# script in unity read this txt file and make the script read the same file say every 10 sec (estimation of the time between receiving information -writing them in text file-reading them by unity). of-curse u should make your matlab code rewrite the update information in the same text file with the same name
You could try writing a simple c# dll to serve as glue. There's an article (requires matlab acct) on how to go about using it within a matlab project.
Unity might then reference the same dll, subscribing to events fired by the matlab side. Have not tried this personally.
What a strange mix :)
I would suggest trying to use UDP sockets. For example, your Unity program opens a UDP server socket in the port 55555. $$anonymous$$atlab sends the measures as UDP frames to the port 55555. It's quite simple if you know about sockets. It's ok if both programs are in the same computer, you can use localhost as the destination address.
have you solved the issue? i am trying to handle with the same stuff currently.
Answer by cap_L · Oct 30, 2018 at 01:28 PM
Hello,
Yes I also want to know if we can use Unity with MATLAB. There are few APIs that only support MATLAB. Did you find any solution @srcarter3 ?
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612001429im_/https://answers.unity.com/themes/thub/images/avi.jpg)