La traducción de esta página está obsoleta. Haga clic aquí para ver la última versión en inglés.
Llamar aMATLABdesdePython
La API del motor 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).MATLAB admite las versiones 2.7, 3.7, 3.8 y 3.9.Para obtener más información, consulteVersiones de Python compatibles con los productos de MATLAB por versión.
Para instalar e iniciar el motor, consulteGet Started with MATLAB Engine API for Python.
Para llamar a las funciones de Python desde MATLAB, consulteLlamar a Python desde MATLAB.
我拉斯维加斯aplicaciones del电动机requieren una版本nstalada de MATLAB; no es posible ejecutar el motor de MATLAB en un equipo que solo tenga MATLAB Runtime.
Funciones
Clases
Temas
Instalación
- System Requirements for MATLAB Engine API for Python
What you need to write and build MATLAB engine applications for Python. - Install MATLAB Engine API for Python
To start the MATLAB engine within a Python session, you first must install the engine API as a Python package. - Install MATLAB Engine API for Python in Nondefault Locations
By default, the installer builds the engine API for Python in the
folder. If you install in another folder, update thematlabroot
\extern\engines\pythonPYTHONPATH
environment variable.
Introducción
- Get Started with MATLAB Engine API for Python
The MATLAB Engine API for Python provides a Python package namedmatlab
that enables you to call MATLAB functions from Python. - Start and Stop MATLAB Engine for Python
Options for starting the MATLAB Engine for Python. - Call MATLAB Functions from Python
How to return an output argument from a MATLAB function. How to read multiple outputs from a function. What to do when the MATLAB function does not return an output argument. - 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
- Use MATLAB Engine Workspace in Python
This example shows how to add variables to the MATLAB engine workspace in Python.
Intercambio y asignación de datos
- Use MATLAB Arrays in Python
This example shows how to create a MATLAB array in Python and pass it as the input argument to the MATLABsqrt
function. - 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. - Pasar datos a MATLAB desde Python
Cuando pasa datos de Python como argumentos de entrada a las funciones de MATLAB, el motor de MATLAB para Python convierte los datos a tipos de datos equivalentes de MATLAB. - Handle Data Returned from MATLAB to Python
When MATLAB functions return output arguments, the MATLAB Engine API for Python converts the data into equivalent Python data types. - 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
MATLAB stores all numeric values as double-precision floating point numbers by default.
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
Limitations to MATLAB Engine API for Python
The MATLAB Engine API does not support these features.
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.