External Interfaces Previous page   Next Page

A First Example -- Passing a Scalar

Let's look at a simple example of Fortran code and its MEX-file equivalent. Here is a Fortran computational routine that takes a scalar and doubles it.

Below is the same function written in the MEX-file format.

To compile and link this example source file, at the MATLAB prompt type

This carries out the necessary steps to create the MEX-file called timestwo with an extension corresponding to the machine type on which you're running. You can now call timestwo as if it were an M-function.


Previous page  Examples of Fortran MEX-Files Passing Strings Next page

© 1994-2005 The MathWorks, Inc.