engOpen (C and Fortran) - Start MATLAB® engine session

C Syntax

#include "engine.h"
Engine *engOpen(const char *startcmd);

Fortran Syntax

mwPointer engOpen(startcmd)
character*(*) startcmd

Arguments

startcmd

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

Returns

A pointer to an engine handle or NULL if the open fails.

Description

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

engOpen 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®[1] systems, if startcmd is NULL or the empty string, engOpen starts a MATLAB process on the current host using the command matlab. If startcmd is a hostname, engOpen starts a MATLAB process on the designated host by embedding the specified hostname string into the larger string:

"rsh hostname \"/bin/csh -c 'setenv DISPLAY\ 
	hostname:0; matlab'\""

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

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) software to two file descriptors in the engine program (child).

  3. Executes a command to run MATLAB software (rsh for remote execution).

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

matlab /regserver

See Introducing MATLAB® COM Integration for additional details.

C Examples

UNIX® Operating Systems

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.

Microsoft® Windows® Operating Systems

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 systems.

Fortran Examples

See fengdemo.F in the eng_mat subdirectory of the examples directory for a sample program that illustrates how to call the MATLAB engine functions from a Fortran program.


[1] UNIX is a registered trademark of The Open Group in the United States and other countries.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS