Chiamata di MATLAB da C
mxArrayLe applicazioni engine sono programmi che consentono di chiamare MATLAB dai programmi C/C++ utilizzando MATLAB come engine computazionale. Per compilare un applicazione engine C, chiamare la funzione mex.
Nota
Si consiglia di utilizzare l'API di MATLAB Engine per C++ anziché l'API di engine per C. L'API di MATLAB Engine per C++ include moderne feature C++ per la scrittura di applicazioni engine. Per maggiori informazioni, vedere Chiamata di MATLAB da C++. Non è previsto alcun piano per rimuovere l'API di Engine per C.
Le applicazioni engine richiedono una versione installata di MATLAB; non è possibile eseguire MATLAB Engine su una macchina che dispone solo del runtime di MATLAB.
Per creare un'applicazione engine C, è necessario:
Avere esperienza nella scrittura di codice sorgente C. È possibile creare file di codice sorgente C utilizzando l'API di Engine per C e le funzioni API Matrix C.
Un compiler supportato da MATLAB. Per un elenco aggiornato dei compilatori supportati, vedere Supported and Compatible Compilers (Compilatori supportati e compatibili).
Utilizzare lo script di compilazione
mexcon l'opzione-client engine.
API di Engine per C
Engine | Type for MATLAB engine |
engOpen | Start MATLAB engine session |
engOpenSingleUse | Start MATLAB engine session for single, nonshared use |
engClose | Quit MATLAB engine session |
engEvalString | Evaluate expression in string |
engGetVariable | Copy variable from MATLAB engine workspace |
engPutVariable | Put variable into MATLAB engine workspace |
engGetVisible | Determine visibility of MATLAB engine session |
engSetVisible | Show or hide MATLAB engine session |
engOutputBuffer | Specify buffer for MATLAB output |
Argomenti
Requisiti
- Requirements to Build Engine C Applications
Install and configure a compiler and run-time environment so you can build C applications to call MATLAB. - Set Up C Development Environment
Set up a development environment to write C applications that call MATLAB functions.
Scrittura di applicazioni engine
- MATLAB Engine APIs for C and Fortran
Call MATLAB from your own C and Fortran programs, using MATLAB as a computation engine. - Call MATLAB Functions from C Applications
Create a C engine applicationengdemo.c. - Attach to Existing MATLAB Sessions
This example shows how to attach an engine program to a MATLAB session on a Windows® platform that is already running. - Callbacks in Applications
Design user interface callbacks to be evaluated in the context of the base workspace.
Compilazione ed esecuzione di applicazioni engine
- Build and Run C Engine Application on Windows
This example shows how to verify the build process on a Windows platform. - Build and Run C Engine Application on macOS
This example shows how to verify the build process on a macOS platform. - Build and Run C Engine Application on Linux
This example shows how to verify the build process on a Linux® platform.
Risoluzione dei problemi
What to do when MATLAB engine does not run.
Debug MATLAB Function Called by C Engine
How to verify MATLAB functions used in engine applications.
Some MATLAB functions that interact with the user are not supported in engine applications.
MATLAB libraries are not thread-safe.