External Interfaces/API Reference    
engOpen

Start a MATLAB engine session

C Syntax

Arguments

startcmd
   String to start MATLAB process. On Windows, the startcmd string must be NULL.

Returns

A pointer to an engine handle.

Description

This routine allows you to start a MATLAB process for the purpose of using MATLAB as a computational engine.

engOpen(startcmd) starts a MATLAB process using the command specified in the string startcmd, establishes a connection, and returns a unique engine identifier, or NULL if the open fails.

On UNIX systems, if startcmd is NULL or the empty string, engOpen starts MATLAB on the current host using the command matlab. If startcmd is a hostname, engOpen starts MATLAB on the designated host by embedding the specified hostname string into the larger string:

If startcmd is any other string (has white space in it, or nonalphanumeric characters), the string is executed literally to start MATLAB.

On UNIX systems, engOpen performs the following steps:

  1. Creates two pipes.
  2. Forks a new process and sets up the pipes to pass stdin and stdout from MATLAB (parent) to two file descriptors in the engine program (child).
  3. Executes a command to run MATLAB (rsh for remote execution).

Under Windows on a PC, engOpen opens a COM channel to MATLAB. This starts the MATLAB that was registered during installation. If you did not register during installation, on the command line you can enter the command:

See Introducing MATLAB COM Integration for additional details.

Examples

UNIX

See engdemo.c in the eng_mat subdirectory of the examples directory for a sample program that illustrates how to call the MATLAB engine functions from a C program.

Windows

See engwindemo.c in the eng_mat subdirectory of the examples directory for a sample program that illustrates how to call the MATLAB engine functions from a C program for Windows.


  engGetVisible engOpenSingleUse