Getting the most from MATLAB: ditching canned routines and embracing coder
John L. Gibson, James P Henson · RePEc: Research Papers in Economics · 2016
This paper demonstrates the efficiency gains that can be realized by replacing canned routine calls within MATLAB with user-generated versions that simplify the underlying computations. Once canned routines have been replaced, we integrate C++ executables (or MEX files) using MATLAB's Coder to automatically convert our MATLAB code. We demonstrate these efficiency gains by computing the stationary equilibria and associated transition path for an economy with incomplete insurance markets following a change in government debt policy. The combined process of replacing calls to canned routines and integrating MEX files reduces our runtime from just over 24 hours to approximately 16 minutes.