Llamar a MATLAB desde Python
La API del motor de MATLAB para Python proporciona un paquete que permite que Python llame a MATLAB como motor de cálculo. El motor es compatible con la implementación de referencia (CPython). Para obtener información sobre versiones compatibles, consulte Versiones de Python compatibles con los productos de MATLAB por versión.
Para instalar e iniciar el motor, consulte Introducción a la API del motor de MATLAB para Python.
Para llamar a las funciones de Python desde MATLAB, consulte Llamar a Python desde MATLAB.
Las aplicaciones del motor requieren una versión instalada de MATLAB; no es posible ejecutar el motor de MATLAB en un equipo que solo tenga MATLAB Runtime.
Funciones
Clases
Temas
Instalación
- Instalar la API del motor de MATLAB para Python
Para iniciar el motor de MATLAB dentro de una sesión de Python, instale la API del motor como un paquete de Python.
Introducción
- Introducción a la API del motor de MATLAB para Python
La API del motor de MATLAB para Python proporciona un paquete de Python llamadomatlab
que le permite llamar a funciones de MATLAB desde Python. - Iniciar y detener el motor de MATLAB para Python
Opciones para iniciar el motor de MATLAB para Python. - Llamar a funciones de MATLAB desde Python
Cómo devolver un argumento de salida de una función de MATLAB. Cómo leer varios valores de salida de una función. Qué hacer cuando la función de MATLAB no devuelve un argumento de salida. - Get Help for MATLAB Functions from Python
From Python, you can access supporting documentation for all MATLAB functions.
Administración de sesiones
- Connect Python to Running MATLAB Session
How to connect the MATLAB Engine for Python to a shared MATLAB session that is already running on your local machine.
Uso del área de trabajo de MATLAB
- Usar el área de trabajo del motor de MATLAB en Python
Este ejemplo muestra cómo añadir variables al área de trabajo del motor de MATLAB en Python.
Intercambio y asignación de datos
- Utilizar arreglos de MATLAB en Python
Este ejemplo muestra cómo crear un arreglo de MATLAB en Python y pasarlo como argumento de entrada a la función de MATLABsqrt
. - MATLAB Arrays as Python Variables
Thematlab
Python module provides array classes to represent arrays of MATLAB numeric types as Python variables so that MATLAB arrays can be passed between Python and MATLAB. - Pass Data Between MATLAB and Python
When you return MATLAB data to Python, MATLAB Engine API for Python converts the data into the equivalent Python data type. - Use MATLAB Handle Objects in Python
This example shows how to create an object from a MATLAB handle class and call its methods in Python. - Default Numeric Types in MATLAB and Python
By default, a number in MATLAB has a double-precision type. - Use MATLAB Dictionaries in Python
MATLAB Engine API for Python converts a Pythondict
to a MATLAB dictionary and a MATLAB dictionary to a Pythondict
. - Use MATLAB Tables and Timetables in Python
Convert between MATLAB tables and timetables and Python pandas DataFrames. - How MATLAB Handles Datetime and Duration Types in Python
Convert between MATLABdatetime
andduration
values and Pythondatetime
andnumpy
types.
Llamar a funciones de MATLAB
- Llamar a scripts y funciones del usuario desde Python
Este ejemplo indica cómo llamar a un script de MATLAB para calcular el área de un triángulo desde Python. - Sort and Plot MATLAB Data from Python
This example shows how to sort data about patients into lists of smokers and nonsmokers in Python and plot blood pressure readings for the patients with MATLAB. - Call MATLAB Functions Asynchronously from Python
This example shows how to call the MATLABsqrt
function asynchronously from Python and retrieve the square root later. - Redirigir salida estándar y error estándar a Python
Este ejemplo muestra cómo redirigir salida estándar y error estándar desde una función de MATLAB a objetosStringIO
de Python.
Solución de problemas
Limitaciones de la API del motor de MATLAB para Python
La API del motor de MATLAB para Python no es compatible con estas funcionalidades.
Troubleshoot MATLAB Errors in Python
When a MATLAB function raises an error, the MATLAB Engine for Python stops the function and catches the exception raised by MATLAB.