Whats the difference between M-files, Pcode, and MEX files?
Suggested by Joshua Stiff: • M-files are plain ASCII text that is interpreted at run time. Actually it is parsed once and “just-in-time” compiled, but this is transparent to the user. Use M-files for most of your MATLAB development, and for platform independence and maintainability. • Pcode is a preparsed and encoded version of the M-file. Since it is preparsed, it saves on the load time of the function. This is most likely not an issue except for very large M-files, since most are parsed only once anyway. Pcode also lets you hide the source code from others. Careful, there is no way to convert Pcode back to the M-file source. Pcode is platform independent. • MEX files are native C or C++ files that are dynamically linked directly into the MATLAB application at runtime. They must be compiled for each hardware architecture on which they are to be run. MEX files have the potential to crash the MATLAB application, but rather large speed gains are possible, depending on the algorithm.