Mathworks haven’t issued a patch for 2012b and OS X 10.9 so I ran the 10.9 patch (from http://www.mathworks.com/matlabcentral/answers/94092) and ran
I then modified the mexopts.sh file (mex -setup tells you where this is, on my system its
In the section called
remove the version numbers from CC and CXX and correct the SDKROOT. I also changed the deployment target to 10.9
After a restart, mex worked fine.