Call Python from MATLAB for Wireless
R2026bBefore you can run wireless simulations that use PyTorch® or TensorFlow™ models, you must first configure your computer to use Python® from MATLAB®. To install a supported python implementation on your computer, see Set Up Python Environment for Deep Learning with PyTorch Workflows (Deep Learning Toolbox) and Use PyTorch and MATLAB for Deep Learning Workflows (Deep Learning Toolbox).
Once you have configured your computer and your MATLAB environment, you can then:
Use MATLAB to generate data sets to train the PyTorch models by leveraging the Wireless Communications toolboxes.
Run simulations with your PyTorch model instantiations in MATLAB by using the
(Deep Learning Toolbox) object and modifying the PyTorch Wrapper Template to implement desired entry points.pyTorchModelTest the PyTorch models in link-level and system-level simulations.
Leverage software-defined radio (SDR) support to test your design with over-the-air (OTA) signals.
Import and deploy your system onto several possible platforms after qualifying your design. For more information, see Interoperability Between Deep Learning Toolbox, TensorFlow, PyTorch, and ONNX (Deep Learning Toolbox).
Try some sample AI applications in Wireless Workflows with MATLAB calling Python.
MATLAB can run Python code in two execution modes:
"InProcess"— Runs Python within the MATLAB process. This mode provides the best performance by eliminating interprocess communication overhead. Use this mode for production workflows."OutOfProcess"— Runs Python in a separate process. This mode allows you to restart the Python environment without restarting MATLAB, which is useful when debugging or iterating on environment configuration.
For more information, see Configure Environment for PyTorch Interface (Deep Learning Toolbox).
Wireless Workflows with MATLAB calling Python
These examples show AI for wireless applications with MATLAB calling Python to run PyTorch models.
Data Preparation
Preprocess Data for AI-Based CSI Feedback Compression (5G Toolbox)
Preprocess Data for AI-Based CSI Prediction (5G Toolbox)
Model Training
Train PyTorch Channel Prediction Models (5G Toolbox)
Train PyTorch Channel Prediction Models with Online Training (5G Toolbox)
Model Testing
Each example includes a requirements supporting file to identify the Python libraries that you need and their specific versions. You can use the
requirements files with the pip command line program to install
all the required libraries. For more information, see https://pip.pypa.io/en/stable/user_guide/.