Force MATLAB to reload library linked in mex function
To clear a library from memory I usually have excellent luck with
bdclose all;
Then if I'm really feeling militant, I'll do:
bdclose all; % clear all libraries out of memory ( supposedly )
clear all; % clear all workspace variables, mex, etc. ( supposedly )
rehash; % cause all .m files to be reparsed when invoked again