Main Content

La traducción de esta página está obsoleta. Haga clic aquí para ver la última versión en inglés.

Llamar aPythondesdeMATLAB

Llame directamente a las funciones de Python®desde MATLAB®

Puede acceder a las bibliotecas de Python directamente desde MATLAB agregando el prefijopy.al nombre Python. ConsulteAccess Python Modules from MATLAB - Getting Started. 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
Puede ejecutar instrucciones de Python en el intérprete de Python directamente desde MATLAB usando las funcionespyrunopyrunfile. Por ejemplo:
pyrun("l = ['A', 'new', 'list']") % Call list in Python interpreter
Para obtener más información, consulteDirectly Call Python Functionality from MATLAB.

Si en su lugar desea llamar a las funciones de MATLAB desde las aplicaciones de Python, consulteLlamar a MATLAB desde Pythonpara obtener más información.

Funciones

expandir todo

pyenv Change default environment ofPythoninterpreter
PythonEnvironment Python environment information
pyrun RunPythonstatements fromMATLAB
pyrunfile RunPythonscript file fromMATLAB
pyargs Create keyword arguments forPythonfunction
matlab.exception.PyException Capture error information forPython异常

Temas

Usar bibliotecas de Python en MATLAB

Ejecutar código de Python desde MATLAB

Paso de datos

Solución de problemas

Determine if Error is Python or MATLAB Error

Tips to determine if an error originates in Python or MATLAB code.

Limitations to Python Support

Python features not supported in MATLAB.

处理Python异常

MATLAB catches exceptions thrown by Python and converts them into amatlab.exception.PyExceptionobject.

Troubleshooting Matrix and Numeric Argument Errors

Error might be caused by input array with more than one non-singleton dimension.