MATLAB: Recompile codegen C code with mex

code generationMATLAB Builder EXmex

With codegen, I can get the executable mex files directly, which is a quite nice feature. However, during development, I may need to use 'codegen' to generate C codes from the .m files and make modification in C. I wonder is there an easy way to recompile the modified C codes and get the executable mex files?
What confuses me is that codegen will create a whole bunch of auxiliary files in addition to the .c files. I guess some files may contain the mex compilation configuration that I can use directly.
Thanks~

Best Answer

There is usually a .bat (or shell script on Linux) that sets up environment variables and runs a makefile (also generated to the same directory). If you modify the source code, simply running the batch/shell script will recompile the binaries. On R2011a, the relevant files are in codegen/mex/<filename>/ and named <filename>_mex.bat and <filename>_mex.mk