I experimented in compiling model generated by dynare with Matlab Compiler. It actually works! The following contains my notes.
It would be nice to hear your experiences on Matlab Compiler and Dynare.
Dynare is a pre-processor to Matlab (and SciLab). It, however, generates a Matlab script that can be compiled. This note explains how to do the job (with Dynare 3 and a simple model).
The name of the script file is the same as the model (e.g. mymodel.mod) with .m (my-model.m). This is the file you are working with, i.e. run dynare first to (1) check that everything works as you expect and (2) to generate the .m file.
First you must check that you have all the necessary path setup by the “File/Set Path”. Matlab Compiler does not accept addpath command.
Since the Compiler does not accept scripts you should add a line
as the first line of mymodel.m file.
You must also include all files that are called by feval function in the Matlab code you are running. Typically this means that you must include mymodel_ff.m and mymodel_fff.m. In the case you use the forecast command, you should also include ffi_.m from your Dynare path. Do not expect that eval –function works always.
Consequently, the following should do the compilation job.
It results mymodel.exe. You may run this from CMD window. In the case you want to run it with another computer without Matlab, you should package it. The packaging etc. stuff you may find from Compiler User Guide.
In the case you see the following error message in running the executable, this means that you need to include the missing file to the mcc command.
??? Error using ==> feval
Undefined function or method 'mymodel_fff' for input arguments of type