Llamar a Python desde MATLAB
Puede acceder a las bibliotecas de Python directamente desde MATLAB agregando el prefijo py.
al nombre Python. Consulte Acceder a módulos de Python desde MATLAB: introducción. Por ejemplo:
py.list({'This','is a','list'}) % Call built-in function list py.textwrap.wrap('This is a string') % Call wrap function in module textwrap
pyrun
o pyrunfile
. Por ejemplo:pyrun("l = ['A','new','list']") % Call list in Python interpreter
Si en su lugar desea llamar a las funciones de MATLAB desde las aplicaciones de Python, consulte Llamar a MATLAB desde Python para obtener más información.
Funciones
Temas
Usar bibliotecas de Python en MATLAB
- Acceder a módulos de Python desde MATLAB: introducción
Cómo crear y usar un objeto de Python en MATLAB. - Configurar su sistema para utilizar Python
Cómo verificar que ha instalado una versión compatible de Python. - Call User-Defined Python Module
Create a Python module used by examples in this documentation. - Understand Python Function Arguments
Python method syntax which might be unfamiliar to MATLAB users. - Advanced Topics
Code pattern differences you should be aware of. - Out-of-Process Execution of Python Functionality
Execute Python scripts in processes that are separate from the MATLAB process. - Volver a cargar un intérprete de Python fuera de proceso
Vuelva a cargar un intérprete de Python fuera de proceso sin reiniciar MATLAB.
Ejecutar código de Python desde MATLAB
- Llamar directamente a funciones de Python desde MATLAB
Formas de llamar a Python desde MATLAB.
Paso de datos
- MATLAB to Python Data Type Mapping
How MATLAB converts MATLAB data into compatible Python data types. - Access Elements in Python Container Types
A Python container is typically a sequence type (list
ortuple
) or a mapping type (dict
). - Pass Python Function to Python map Function
This example shows how to display the length of each word in a list.
Solución de problemas
Determine if Error is Python or MATLAB Error
Tips to determine if an error originates in Python or MATLAB code.
Python features not supported in MATLAB.
MATLAB catches exceptions thrown by Python and converts them into a matlab.exception.PyException
object.
Troubleshooting Matrix and Numeric Argument Errors
Error might be caused by input array with more than one non-singleton dimension.
Error Converting Elements of list or tuple
How to use string and numeric converters for list
and
tuple
types.