Calling a python file from matlab/simulink
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear all,
I have a dataset and I have to apply different machine learning algorithms in it. Because I am more proficient in Python, I considered writing the code in Python.
Now I have a Python file that runs flawlessly and returns the predicted values. However, there is a global simulation environment in which these values must be integrated, and this global simulation environment is based on Matlab/Simulink.
I'm thinking about modeling 1D look-up tables in Simulink using the output dataset from the executed Python file. My question is, how do I get Simulink to call the Python file?
Example: A user runs the global environment model in Matlab/Simulink that calls the python file, the python files executes and saves the output in .csv format, and the look-up tables are updated and accessed in the workspace of matlab that are eventually run in Simulink.
댓글 수: 0
답변 (1개)
David Willingham
2022년 9월 14일
Hi Rehan,
What application is the python model being used for? In simulink, do you need the model to run every time step or do you only need to run prior to the start or end of a simulation? I see you gave some use cases but it's not 100% clear.
댓글 수: 2
David Willingham
2022년 9월 15일
Hi Rehan,
Thanks for providing the additional context to the problem you're working on. It is very helpful to hear.
There is a post that describes how to call Python via the MATLAB function block in Simulink:
Try using this method, if you have questions please don't hesitate to reply here.
David
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!