Calling a python file from matlab/simulink

2 visualizaciones (últimos 30 días)
Rehan Khan
Rehan Khan el 14 de Sept. de 2022
Comentada: David Willingham el 15 de Sept. de 2022
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.

Respuestas (1)

David Willingham
David Willingham el 14 de Sept. de 2022
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 comentarios
David Willingham
David Willingham el 15 de Sept. de 2022
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.

Iniciar sesión para comentar.


Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by