GENMEX is a utility to automatically generate MATLAB MEX-files that call Fortran (especially NAG) library routines. Take a look at an example on how to use NAG's minimization routine e04dgf from MATLAB. There is also a paper describing the basic principles. GENMEX is written and tested in SUN Solaris 2.3 environment and depends on way how fortran routines are called from c-language in Solaris. It should however work now on some other platforms too (IRIX, AIX, Linux).