MATLAB Live Task for Python
Updated 5 May 2022
The MATLAB® Live Task for Python® enables you to write and execute Python code directly inside of a MATLAB Live Script. Since R2022a, MATLAB provides a way to develop your own custom live task.
- MATLAB R2022a or later
- Python (supported Python versions by MATLAB release can be found here)
install script to add the required paths to your MATLAB environment and configure the MATLAB Live Task for Python. Click 'Ok' when promtped with the following UI to configure the Live Editor task metadata:
To insert the live task in your live script:
Go to the Live Editor tab in the Editor Toolstrip and select Task:
Then, choose the live task under the MY TASKS category:
Alternatively you may simply type
python and the autocomplete feature will suggest the appropriate task:
This is what the MATLAB Live Task for Python looks like:
First, create a variable in the MATLAB workspace:
>> T = 'We at MathWorks believe in the importance of engineers and scientists. They increase human knowledge and profoundly improve our standard of living.';
The Python input and output variables can be mapped with variables in the MATLAB workspace:
You can choose to write either Python statements or a Python script file:
and retrieve the required variables to be used back in MATLAB:
>> wrapped = string(wrapped)' wrapped = 6×1 string array "% We at MathWorks believe in" "% the importance of engineers" "% and scientists. They" "% increase human knowledge and" "% profoundly improve our" "% standard of living."
You can find examples on how to use the MATLAB Live Task for Python in the
examples folder within this repository.
Technical issues or enhancement requests can be submitted here.
The license is available in the License file within this repository
Copyright © 2022 MathWorks, Inc. All rights reserved.
"Python" and the Python logos are trademarks or registered trademarks of the Python Software Foundation, used by MathWorks with permission from the Foundation.
Lucas García (2022). MATLAB Live Task for Python (https://github.com/mathworks/MATLAB-Live-Task-for-Python/releases/tag/v1.0.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!