Matlab Compiler and Dynare

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Matlab Compiler and Dynare

Postby ripatti » Wed Apr 09, 2008 12:22 pm

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.

Regards,
Antti

**********************

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
Code: Select all
function mymodel

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.
Code: Select all
mcc -m mymodel.m mymodel_fff.m mymodel_ff.m c:\dynare\matlab\ff1_.m;


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.
Code: Select all
??? Error using ==> feval
Undefined function or method 'mymodel_fff' for input arguments of type
'double'.
ripatti
 
Posts: 59
Joined: Mon Jan 16, 2006 6:28 am
Location: Helsinki

Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 6 guests