将 Python 代码集成到 Simulink 中
将具有 Python® 代码的算法集成到 Simulink® 中
Simulink 允许您实现使用 Python 代码设计的算法。您可以使用 MATLAB Function 模块、MATLAB System 模块或 Python 导入器在 Simulink 中实现 Python 模块。对于简单算法的实现,请使用 MATLAB Function 模块。对于需要处理状态动态、流数据和其他模块自定义的算法,请使用 MATLAB System 模块。Python 导入器使您能够通过为指定函数生成自定义模块,将 Python 模块导入 Simulink 中。
有关在 MATLAB® 中使用 Python 的详细信息,请参阅从 MATLAB 中调用 Python。
模块
| Python Code | Integrate native Python code into a Simulink model (自 R2025a 起) |
主题
- 将 Python 代码与 Simulink 集成的概述
使用 MATLAB Function 模块或 MATLAB System 模块将 Python 代码与 Simulink 集成。
- Integrate Python Code into Simulink Using Python Code Block
Integrate native Python code, define interfaces and block algorithm, and run simulations in Simulink.
- Import Python Code to Simulink Using Python Importer Wizard
Use the Python Importer to Import Python Modules and Packages to Simulink.




