Here is a workaround for setting up mex in MATLAB2015a within MacOS Yosemite.
You need to install two software packages: Command Line Tools (CLT) and gfortran.
1. Installation of CLT
Simply download the following and install. (You need Xcode 6.3 or higher as a prerequisite).
https://developer.apple.com/downloads/index.action?name=for%20Xcode
2. Installation of gfortlan
go to the following site and download gfortran 5.0
http://hpc.sourceforge.net/
Direct download link for gfortran 5.0
You will have gfortran-5.0-bin.tar in your downloaded folder.
Open terminal console and type the following for gfortran installation
sudo tar -xvf gfortran-5.0-bin.tar -C /.
Note that don’t forget “/.” at the end of the command line.
You will see some log messages copying files into your /usr/local/bin and related folders.
Done!
For verification, just type “mex -setup FORTRAN” in MATLAB console. This should show you the following message.
MEX configured to use 'gfortran' for FORTRAN language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.