This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Pass Scalar Values

Here is a Fortran computational routine that takes a scalar and doubles it.

      subroutine timestwo(y, x)
      real*8 x, y
      y = 2.0 * x

To see the same function written in the MEX file format (timestwo.F), open the file in MATLAB® Editor.

To build this example, at the command prompt type:

mex timestwo.F

This command creates the binary MEX file called timestwo with an extension corresponding to the machine type on which you are running. You can now call timestwo like a MATLAB function:

x = 2;
y = timestwo(x)
y =
Was this topic helpful?