diego domenzain March 2021 @ Colorado School of Mines
Taken from the Matlab docs.
See here for more examples.
An example with matrix I/O can be found in
projects/pdes/hdd/src/hhd_solve.F
which is used in
projects/pdes/hdd/src/hhd_.m & projects/pdes/hdd/hhd_cooler.m
Main Fortran routine is,
/Applications/MATLAB_R2014b.app/extern/examples/refbook/timestwo.F
The header needed for this to work is,
/Applications/MATLAB_R2014b.app/extern/include/fintrf.h
To compile and use do:
>> mex -v timestwo.F
>> x = 99;
>> y = timestwo(x)
C Gateway routine
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C Declarations
C Statements
return
end
In my experience, this was quite annoying.
First, check which versions you have of these:
$> xcrun --show-sdk-version
$> xcodebuild -showsdks
Then in Matlab type,
>> compilerCfg = mex.getCompilerConfigurations
>> open(compilerCfg(1).MexOpt)
Alternatively, you can just open this file,
/Users/username/.matlab/R2014b/mexopts.sh
Then edit this file with the right versions.