How did you manage it in the latests Matlab versions?
@miz35673 жыл бұрын
@@alex972011 My Matlab version is R2016b, it works fine with this code.
@mohamedrizk46584 жыл бұрын
you are a lifesaver
@ivancamponogara65784 жыл бұрын
Thanks Mohamed! I’m glad you found the tutorial useful 😊 the only thing I couldn’t figure out is how to reduce the delay, just let me know if il you have some tips for it.
@mohamedrizk46584 жыл бұрын
@@ivancamponogara6578 in c# you open a tcp port which is one end of the port(pipe) .when you open the pory in matlab you open the other end; then unity freeze to receive data meanwhile matlab start to send data in the port and then close the pipe. closing the port signal to c# you have received all data[ reader.readtoend();] and it can progress in code. keep in mind opening the port and closing it (to approve you have send all data) take along time .3 s what should happens is that, c# should have a buffer with a fixed size (the size of string of data); and you should not close the pipe. but you should stream the data continues from matlab ,and c# should wait until its fixed size buffer become fill then it continue it process and all other data that matlab send it will be stored in the pipe waiting for c# to call read again how to do that in c# i have no idea
@ivancamponogara65784 жыл бұрын
Super thanks! I'll work on it and let you know if I have some news!
@lsx14044 жыл бұрын
hello,can you share your c# code?
@zhenisotarbay5159 Жыл бұрын
Installed Psychtoolbox-3, but still: Error using KbName (line 861) Key name "ESCAPE" not recognized. Maybe you need to add KbName('UnifyKeyNames'); to top of your script? Error in Code_Moving_Cylinder_with_arrows (line 7) escapeKey = KbName('ESCAPE');
@huangzheng6580 Жыл бұрын
Did you fix it? I want to use Psychtoolbox-3 to present picture arrays and send markers to EEG devices, I do not know whether I can do it
@huangzheng6580 Жыл бұрын
thank you a lot, It works! However, there is an issue with delays. As I press a key(for example, a left key), it wont move immediately, it will delay for seconds and then move, how to solve this problem?
@ivancamponogara6578 Жыл бұрын
Hi Huang, yes, that was the central issue. If you find a way to solve it, let me know!
@ahmadyounis75375 жыл бұрын
Hello thanks for you important information. would you please tell us how to model this work(tcp) to send data using simulink.
@ivancamponogara65785 жыл бұрын
HI Ahmad, unfortunately I have no idea. You might find something around youtube.
@zhenisotarbay5159 Жыл бұрын
Which matlab version did you use?
@arunsebastian28252 жыл бұрын
Hi , How can I play and stop a video in Unity using MATLAB? (I'm new to Unity). Thanks
@ivancamponogara65782 жыл бұрын
You should try merging this docs.unity3d.com/Manual/class-VideoPlayer.html with this stackoverflow.com/questions/41562023/how-to-play-video-in-unity-2d and something in Matlab like this www.mathworks.com/matlabcentral/answers/154565-how-do-i-stop-or-pause-a-video-in-matlab-gui-activex-windows-media-player best of luck for the project!
@chewchew99 Жыл бұрын
Hi Ivan, great video! I followed all instructions but I am still unable to command the cylinder in Unity to move. It feels like the connection between MATLAB and Unity is not established. Any idea on how to fix it?
@ivancamponogara6578 Жыл бұрын
Hi! Sorry for the late reply. It looks like a problem related to the client setting (line 6 Matlab code, tcpipClient command). Try to figure out which client you should use. It may be that since 2019 Matlab has also changed some commands. I have never used this code since then, so I don't know if Matworks changed some settings of the tcpipClient command. Hope this somehow helps!
@chewchew99 Жыл бұрын
@@ivancamponogara6578 Thanks a lot!
@mariaandreasanchezcifuente47433 жыл бұрын
you should explain how to make the connection step by step the video is good but sometimes it loses
@Thomse1003 жыл бұрын
Hello Ivan Camponogara. Is it also possible to build an application for Android devices with the method shown, or is the method only accessible for the Unity Editor?
@ivancamponogara65783 жыл бұрын
Hi! What kind of app you have in your mind? It is not clear to me what would be the main function of the app
@Thomse1003 жыл бұрын
@@ivancamponogara6578 I am planning a thesis in the form of simulation software for the Oculus Quest. The Oculus Quest runs on the operating system: Android. Therefore, I wanted to use Matlab for the calculations and Unity for the visualization, if that is possible.
@ivancamponogara65783 жыл бұрын
@@Thomse100 I never tried it with the Oculus quest, but I think that if you want to use this method on the oculus, you will have to attach the quest on a computer and feed the oculus with real time data coming from Unity, which, in turn, receives real time data from Matlab. I don't think you can make a standalone app where Matlab is making the calculation, and upload it into the oculus. Matlab and Unity are two different softwares, so they need to be installed in the same device to work together. In other words, you can use the Oculus as "display" while it's attached to your computer. Does it make sense?
@Thomse1003 жыл бұрын
@@ivancamponogara6578 I understand. I also guess that the Oculus Quest cannot compile Matlab applications. Thanks for the quick feedback.
@ivancamponogara65783 жыл бұрын
@@Thomse100 no problem! Maybe there is a way via C# to feed some oculus data in real time to the unity based app and make the calculations, but I’m not sure. Moreover I don’t know what will be the computational time of the oculus, since it will be busy rendering the environment
@haoxinwu13364 жыл бұрын
Hello thank you so much,I want to know could unity&matlab Implement function:I wrote a piece of matlab code in text format in unity,and send it to matlab,then use matlab compile it?(sorry ,my English is limited)
@ivancamponogara65784 жыл бұрын
Yes,but if you want to send commands from unity to matlab then you have to reverse the communication.in my video,matlab send commands to unity.in your case you want unity to send commands to matlab.therefore,you have to switch the communication between them and make matlab “listen” to unity. You can do it by changing the “client” and “server” functions in the codes. You can find some tips here www.mathworks.com/matlabcentral/answers/196774-connection-between-matlab-and-unity3d
@haoxinwu13364 жыл бұрын
@@ivancamponogara6578 ok ,thank you very much
@haoxinwu13364 жыл бұрын
could i know your email address?i have some questions about unity and matlab
@faisal22065 жыл бұрын
Place your can programe fuzzy logic control BMP180 with arduino to matlab ??
@ivancamponogara65785 жыл бұрын
Faisal I have no idea of what you are talking about
@mrkimo19974 жыл бұрын
Hello, thank you so much for this tutorial but there is a problem with the connection as following: Error using icinterface/fopen (line 83) Unsuccessful open: Connection refused I have checked that my firewall allows this connection and that port 55001 is open through telnet in cmd, I have also double checked the code, so is there something I'm missing ?
@ivancamponogara65784 жыл бұрын
Hi Karim! Have you checked also the c# script?
@mrkimo19974 жыл бұрын
@@ivancamponogara6578 yes I did, I triple checked again now and even compared with the video and the downloaded files.. the communication codes seems fine to me.
@ivancamponogara65784 жыл бұрын
Which o.s. are you using? Matlab version?
@mrkimo19974 жыл бұрын
@@ivancamponogara6578 Windows 10 pro x64 and Matlab version is R2018a
@ivancamponogara65784 жыл бұрын
Could this answer help ? www.mathworks.com/matlabcentral/answers/41455-how-do-use-fopen-properly-everytime-i-try-i-recieve-an-error
@zhenisotarbay5159 Жыл бұрын
Hello, could you please share s charp code not rtf?
@ivancamponogara6578 Жыл бұрын
Isn't it just a matter of copying and pasting the code into the Unity editor?
@perizatinirbaeva507 Жыл бұрын
@@ivancamponogara6578 it has some garbage which is not related to c sharp code like /u3829ndjej
@ivancamponogara6578 Жыл бұрын
@@perizatinirbaeva507 If I download the file and open it with a text editor, I can see the code without the rubbish you are referring to. If I then copy and paste the content from the text file to C sharp, I can't see any rubbish on the code.
@zhenisotarbay5159 Жыл бұрын
Kbname not defined
@ivancamponogara6578 Жыл бұрын
You should download the psychtoolbox in Matlab. If you type "kbname matlab" on google you will be redirected here psychtoolbox.org/docs/KbName They may have changed something in the years, and kbname may have changed in something else. Just have a check.