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!