External Interfaces Previous page   Next Page

Examples of Calling Engine Functions

This section contains examples that illustrate how to call engine functions from C and Fortran programs. The examples cover the following topics:

It is important to understand the sequence of steps you must follow when using the engine functions. For example, before using engPutVariable, you must create the matrix and populate it.

After reviewing these examples, follow the instructions in Compiling and Linking Engine Programs to build the application and test it. By building and running the application, you will ensure that your system is properly configured for engine applications.

Calling MATLAB from a C Application

This program, engdemo.c, illustrates how to call the engine functions from a stand-alone C program. For the Windows version of this program, see engwindemo.c in the <matlab>\extern\examples\eng_mat directory. Engine examples, like the MAT-file examples, are located in the eng_mat directory.

The first part of this program launches MATLAB and sends it data. MATLAB then analyzes the data and plots the results.

The figure is entitled position vs. time for a falling object. The x axis is labeled time (seconds). The y axis is labeled position (meters).

The program then continues with

Pressing Return continues the program.

Entering X = 17.5 continues the program execution.

Finally, the program frees memory, closes the MATLAB engine, and exits.


Previous page  GUI-Intensive Applications Calling MATLAB from a Fortran Application Next page

© 1994-2005 The MathWorks, Inc.