User`s guide
2 Installation and Configuration
2-22
The setup option copies the appropriate options file to your user profile
directory. To make your user-specific changes to the options file, you edit your
copy of the options file in your
user profile directory to correspond to your
specific needs and save the modified file. After completing this process, the
mex
script will use the new options file everytime with your modified settings.
Temporarily Changing the Compiler. To temporarily change your C or C++ compiler,
use the
-f option, as in
mex -f <file>
The -f option tells the mex script to use the options file, <file>. If <file> is not
in the current directory, then
<file> must be the full pathname to the desired
options file. Using the
-f option tells the mex script to use the specified options
file for the current execution of
mex only; it does not reset the default compiler.
Creating MEX-Files
The <matlab>\extern\examples\mex directory contains C source code for the
example
yprime.c. To verify that your system can create MEX-files, enter at
the MATLAB prompt
cd([matlabroot '\extern\examples\mex'])
mex yprime.c
This should create the yprime.dll MEX-file. MEX-files created on Windows
always have the extension
dll.
You can now call
yprime as if it were an M-function. For example,
yprime(1,1:4)
ans =
2.0000 8.9685 4.0000 -1.0947
If you encounter problems generating the MEX-file or getting the correct
results, refer to “External Interfaces/API” in the MATLAB documentation for
additional information about MEX-files.
MATLAB Add-In for Visual Studio
The MathWorks provides a MATLAB add-in for the Visual Studio development
system that lets you work easily within the Microsoft Visual C/C++ (MSVC)
environment to create and debug MEX-files. The MATLAB add-in for Visual
Studio is included with MATLAB and is automatically installed when you run