필터 지우기
필터 지우기

Real-time communication between python and Simulink.

조회 수: 4 (최근 30일)
Narayani
Narayani 2014년 7월 31일
답변: Yongjian Feng 2021년 11월 20일
I have a script running in Python that reads data from a HID USB device ( logitech driving force gt ). I want to use this data as the input to the Simulink model. Currently, I save the read-data into a .mat file and access it in MATLAB. This is less intuitive and I would want to implement it in such a way that the data read in Python is available to the Simulink model real-time. Is there a way to do it?
  댓글 수: 2
Afraz MEHMOOD CHAUDHRY
Afraz MEHMOOD CHAUDHRY 2020년 8월 25일
Well nobody replied to your question and me also facing same problem. Have you find any way to do that. I also need to integrate simulink with python. One way is to call .m script in python whereas simulink file is already called in .m script. But I dont think so that dta from workspace of matlab will be output to python in real time.
Zhanhao Liang
Zhanhao Liang 2021년 11월 18일
Hi Narayani and Afraz, have you guys already solved this problem and been willing to share?
I also want to get real-time data from/to Simulink to/from Python and just knew i can use the To Workspace block in simulink to send data from Simulink to Matlab then use matlab.engine in Python to get it, but it is just not real time.

댓글을 달려면 로그인하십시오.

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 11월 20일
Interesting. It is an old question but users are still interested in this.
How about this approach? Go through a server. On the python side, run a flask server. It has a thread to read the data. Matlab code pull data periodically from the flask server.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by