Watch this Author's files
A few tips...
In 64-bit systems:
Be sure to compile netcdi, and cdf libraries with -fPIC enabled.
In newer versions of MATLAB: open cdi_mx.c and replace the obsolete function mxErrMsgIdAndTxt with something else (or just comment out). I succesfully used mexprintf instead.