Using MATLAB with Python

MATLAB® provides a flexible, two-way integration with many programming languages, including Python®. This allows different teams to work together and use MATLAB algorithms within production software and IT systems.

Calling MATLAB from Python

The MATLAB Engine API for Python allows you to call MATLAB as a computational engine from Python.

The API lets you execute MATLAB commands from within your Python environment without starting a desktop session of MATLAB. Learn more about the MATLAB Engine API for Python.

Calling Python Libraries from MATLAB

If you have functions and objects in Python, you can call them directly from MATLAB.

This allows you to work entirely within MATLAB without switching your programming environment. Learn more about calling Python libraries from MATLAB.

Packaging MATLAB Programs for Scalable Deployment with Python

Write algorithms and applications in MATLAB, and package and share them with just one click. You can build Python packages from MATLAB programs by using MATLAB Compiler SDK™. These packages can be integrated with Python applications that, in turn, can be shared with desktop users or deployed to web and enterprise systems, royalty-free. Learn more about integrating compiled MATLAB programs into Python applications.

Scale up your MATLAB programs to concurrently access and serve a system of databases, web, and enterprise applications by deploying the programs to MATLAB Production Server™. The server provides integration within your IT architecture via lightweight client API libraries (that include Python) and a RESTful/JSON interface.

 

Interoperability

Using MATLAB with Python for AI

You can exchange deep learning models between MATLAB and Python. This includes importing models from PyTorch®, TensorFlow™, and ONNX models, and exporting networks to TensorFlow and ONNX with a single line of code. You can also co-execute Python-based models in MATLAB and Simulink.

When you import a model into MATLAB, you can use it with all MATLAB built-in tools for AI. These tools include functions and apps for:

  • Transfer learning
  • Explainable AI and verification
  • System-level simulation and testing
  • Network compression
  • Automatic code generation for target deployment

Pass data between MATLAB and Python with Parquet

Use Apache Parquet to store and transfer tabular data between MATLAB and Python. MATLAB efficiently reads and writes data in Parquet files using Apache Arrow.