Appeler MATLAB à partir de Python
MATLAB Engine API pour Python propose un package pour que Python appelle MATLAB en tant que moteur de calcul. Le moteur supporte l’implémentation de référence (CPython). Pour plus d’informations sur les versions supportées, consultez Versions of Python Compatible with MATLAB Products by Release (Versions de Python compatibles avec les produits MATLAB par version).
Pour installer et démarrer le moteur, consultez Démarrer avec MATLAB Engine API pour Python.
Pour appeler des fonctions Python depuis MATLAB, consultez Appeler Python à partir de MATLAB.
Les applications Engine nécessitent une version installée de MATLAB. Vous ne pouvez pas exécuter MATLAB Engine sur un ordinateur seulement équipé de MATLAB Runtime.
Fonctions
Classes
Rubriques
Installation
- Installer MATLAB Engine API pour Python
MATLAB Engine API pour Python permet d’appeler des fonctions MATLAB et d’exécuter des commandes MATLAB depuis un environnement Python. Pour utiliser le moteur MATLAB, vous devez avoir installé une version supportée de Python sur votre machine. Vous devez également installer MATLAB Engine API pour Python en tant que package Python.
Pour commencer
- Démarrer avec MATLAB Engine API pour Python
MATLAB Engine API pour Python propose un package Python nommématlabqui permet d’appeler des fonctions MATLAB à partir de Python. - Start and Stop MATLAB Engine for Python
Options for starting the MATLAB Engine for Python. - Appeler des fonctions MATLAB à partir de Python
Comment renvoyer un argument en sortie à partir d’une fonction MATLAB. Comment lire plusieurs sorties à partir d’une fonction. Comment procéder lorsque la fonction MATLAB ne renvoie pas d’argument en sortie. - Get Help for MATLAB Functions from Python
From Python, you can access supporting documentation for all MATLAB functions.
Gestion des sessions
- 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.
Utiliser l’espace de travail MATLAB
- Use MATLAB Engine Workspace in Python
This example shows how to add variables to the MATLAB engine workspace in Python.
Échange et mapping de données
- 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 MATLABsqrtfunction. - MATLAB Arrays as Python Variables
ThematlabPython 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 Pythondictto 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 MATLABdatetimeanddurationvalues and Pythondatetimeandnumpytypes.
Appeler des fonctions MATLAB
- Call User Scripts and Functions from Python
This example shows how to call a MATLAB script to compute the area of a triangle from 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 MATLABsqrtfunction asynchronously from Python and retrieve the square root later. - Redirect Standard Output and Error to Python
This example shows how to redirect standard output and standard error from a MATLAB function to PythonStringIOobjects.
Résolution des problèmes
Limitations to MATLAB Engine API for Python
MATLAB Engine API for Python 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.