Main Content

Call MATLAB Functions from Fortran Applications

The program fengdemo.F, in the matlabroot/extern/examples/eng_mat folder, illustrates how to call the engine functions from a standalone Fortran program. To see the code, open this file.

Executing this program starts MATLAB®, sends it data, and plots the results.

Plot from fengdemo engine application.

The program continues with:

Type 0 <return> to Exit
Type 1 <return> to continue

Entering 1 at the prompt continues the program execution:

1
 MATLAB computed the following distances:
   time(s)  distance(m)
   1.00     -4.90    
   2.00     -19.6    
   3.00     -44.1    
   4.00     -78.4    
   5.00     -123.    
   6.00     -176.    
   7.00     -240.    
   8.00     -314.    
   9.00     -397.    
   10.0     -490.    

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

Related Topics