Documentation Center

  • Trial Software
  • Product Updates

Build MEX-File

This example shows how to build the example MEX-file, timestwo. Use this example to verify the build configuration for your system.

To build a code example, first copy the file to a writable folder, such as c:\work, on your path:

copyfile(fullfile(matlabroot,'extern','examples','refbook',...
  'timestwo.c'), fullfile('c:','work'), 'f');

Use the mex function to build the MEX-file.

mex timestwo.c
Building with 'Microsoft Visual C++ 2010 (C)'.
MEX completed successfully.

This command creates the file timestwo.ext, where ext is the value returned by the mexext function.

The timestwo function takes a scalar input and doubles it. Call timestwo as if it were a MATLAB® function.

timestwo(4)
ans =
     8

See Also

|

More About

Was this topic helpful?