Uploaded September 2026 | Updated November 2026, 2 days ago
Have Python® code you want to use in Simulink®? In this demonstration, you’ll learn how to integrate native Python code directly into a Simulink model using the Python Code block.
Explore the entire process, including setting up your environment, importing a module, defining inputs and outputs, and executing code at each simulation step. You’ll also see how stateful logic—such as a filter that depends on previous inputs and outputs—can be incorporated into a model without rewriting the original implementation.
By the end of the demonstration, you will know how to combine existing Python algorithms or libraries with system-level modeling and simulation in only a few steps.
Learn more:
- Access the example shown in this video: bit.ly/4pHzf3L
- Configure your system to use Python: bit.ly/4pIzETA
- Explore the Python Code block documentation: bit.ly/45tI0Fm
- Python in Simulink documentation: bit.ly/4fG9bBw
- Python in MATLAB documentation: bit.ly/3rKn4nA
Chapters:
0:00 Introduction
0:26 The Python code
0:42 Configure the environment
1:16 The Simulink model
1:54 Understand and configure the Python Code block
4:00 Run the simulation
4:14 Conclusion
--------------------------------------------------------------------------------------------------------
Get a free product trial: goo.gl/ZHFb5u
Learn more about MATLAB: goo.gl/8QV7ZZ
Learn more about Simulink: goo.gl/nqnbLe
See what's new in MATLAB and Simulink: goo.gl/pgGtod
© 2026 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.
See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.
Have Python® code you want to use in Simulink®? In this demonstration, you’ll learn how to integrate native Python code directly into a Simulink model using the Python Code block.
Explore the entire process, including setting up your environment, importing a module, defining inputs and outputs, and executing code at each simulation step. You’ll also see how stateful logic—such as a filter that depends on previous inputs and outputs—can be incorporated into a model without rewriting the original implementation.
By the end of the demonstration, you will know how to combine existing Python algorithms or libraries with system-level modeling and simulation in only a few steps.
Learn more:
- Access the example shown in this video: bit.ly/4pHzf3L
- Configure your system to use Python: bit.ly/4pIzETA
- Explore the Python Code block documentation: bit.ly/45tI0Fm
- Python in Simulink documentation: bit.ly/4fG9bBw
- Python in MATLAB documentation: bit.ly/3rKn4nA
Chapters:
0:00 Introduction
0:26 The Python code
0:42 Configure the environment
1:16 The Simulink model
1:54 Understand and configure the Python Code block
4:00 Run the simulation
4:14 Conclusion
--------------------------------------------------------------------------------------------------------
Get a free product trial: goo.gl/ZHFb5u
Learn more about MATLAB: goo.gl/8QV7ZZ
Learn more about Simulink: goo.gl/nqnbLe
See what's new in MATLAB and Simulink: goo.gl/pgGtod
© 2026 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc.
See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.










