User`s manual
1 Calling C and Fortran Programs from MATLAB
1-16
The default options file:
"C:\WINNT\Profiles\username\ApplicationData\MathWorks\MATLAB\R12
\mexopts.bat" is being updated from ...
If the specified compiler cannot be located, you are given the message:
The default location for compiler-name is directory-name,
but that directory does not exist on this machine.
Use directory-name anyway [y]/n?
Using the setup option sets your default compiler so that the new compiler is
used every time you use the
mex script.
Building the MEX-File on Windows
There is example C source code, yprime.c, and its Fortran counterpart,
yprimef.f and yprimefg.f, included in the <matlab>\extern\examples\mex
directory, where
<matlab> represents the top-level directory where MATLAB
is installed on your system.
To compile and link the example source file on Windows, at the MATLAB
prompt, type
cd([matlabroot '\extern\examples\mex'])
mex yprime.c
This should create the MEX-file called yprime with the .DLL extension, which
corresponds to the Windows platform.
You can now call
yprime as if it were an M-function.
yprime(1,1:4)
ans =
2.0000 8.9685 4.0000 -1.0947
To try the Fortran version of the sample program with your Fortran compiler,
switch to your Fortran compiler using
mex -setup. Then, at the MATLAB
prompt, type
cd([matlabroot '\extern\examples\mex'])
mex yprimef.f yprimefg.f