Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

MATLAB Engine API for C, C++, and Fortran

Call MATLAB® from C/C++ and Fortran programs

Engine applications are standalone C/C++ or Fortran programs that allow you to call MATLAB from your own programs, using MATLAB as a computation engine. Engine applications require an installed version of MATLAB; you cannot run the MATLAB engine on a machine that only has the MATLAB Runtime.

C and Fortran Engine Library Functions

engOpen (C and Fortran) Start MATLAB engine session
engOpenSingleUse (C) Start MATLAB engine session for single, nonshared use
engClose (C and Fortran) Quit MATLAB engine session
Engine (C) Type for MATLAB engine
engEvalString (C and Fortran) Evaluate expression in string
engGetVariable (C and Fortran) Copy variable from MATLAB engine workspace
engPutVariable (C and Fortran) Put variable into MATLAB engine workspace
engGetVisible (C) Determine visibility of MATLAB engine session
engSetVisible (C) Show or hide MATLAB engine session
engOutputBuffer (C and Fortran) Specify buffer for MATLAB output

Functions

mex Build MEX function from C/C++ or Fortran source code

Topics

Write Engine Applications

Getting Started

What you need to start building C/C++ or Fortran engine applications.

Introducing MATLAB Engine API for C/C++ and Fortran

Call MATLAB from your own C/C++ and Fortran programs, using MATLAB as a computation engine.

Call MATLAB Functions from C/C++ Applications

Create a C engine application engdemo.c.

Call MATLAB Functions from Fortran Applications

Create a Fortran engine application fengdemo.F.

Attach to Existing MATLAB Sessions

This example shows how to attach an engine program to a MATLAB session that is already running.

Callbacks in Applications

Design user interface callbacks to be evaluated in the context of the base workspace.

Windows Applications

Set Run-Time Library Path on Windows Systems

At run time, tell the operating system where the API shared libraries are by setting the Path environment variable.

Build Windows Engine Application

This example shows how to verify the build process on Windows® platforms using the C example engwindemo.c.

Run Windows Engine Application

This example shows how to run the C example, engwindemo.c, from the Windows system prompt.

Register MATLAB as a COM Server

Register MATLAB for every session, to ensure that the current version of MATLAB is the registered version. If you run older versions, the registered version could change.

Mac Applications

Set Run-Time Library Path on Mac Systems

Tell the operating system where the API shared libraries are by setting the DYLD_LIBRARY_PATH environment variable.

Build Mac OS X Engine Application

This example shows how to verify the build process on a Mac OS X platform.

Run Mac Engine Application

This example shows how to run the C example engdemo.c from the Mac Terminal Window.

Linux Applications

Set Run-Time Library Path on Linux Systems

Tell the operating system where the API shared libraries are by setting the LD_LIBRARY_PATH environment variable.

Build Linux Engine Application

This example shows how to verify the build process on a Linux® platform.

Run Linux Engine Application

This example shows how to run the C example engdemo.c from the Linux system prompt.

Build in Integrated Development Environment

Build Engine Applications with IDE

Tips to configure your integrated development environment to build engine applications.

Troubleshooting

Can't Start MATLAB Engine

What to do when MATLAB engine does not run.

Debug MATLAB Functions Used in Engine Applications

How to verify MATLAB functions used in engine applications.

User Input Not Supported

MATLAB functions that interact with the user or disrupt program flow are not supported in engine applications.

Multithreaded Applications

MATLAB libraries are not thread-safe.

Was this topic helpful?