Error using eval Must be a text scalar Error when Matlab is running Dynare driver code


I’m trying to run Thomas Winberry’s code for solving Krusell-Smith (see attached). When I run the dynamics.m file, when Dynare is running I get an error that says:

Error using eval
Must be a text scalar.

Error in firstOrderDynamics_polynomials.driver (line 3386)
M_.params(iParam) = eval(['economicParameters.' parameterName]);

Error in dynare (line 281)
    evalin('base',[fname '.driver']);

Error in dynamics (line 74)
	dynare firstOrderDynamics_polynomials

I assume this is a Dynare error because the firstOrderDynamics_polynomials.driver is m code generated by Matlab. I have run it on Dynare 5.0 and 5.1 on matlab 2020b. How should I fix this? Thanks for your help,

Cameron (1010.1 KB)

That looks like an incompatibility in the toolkit with recent Dynare versions.

Have you find any solution for this?

An updated version for Dynare 5 is available at


Thank you so much @jpfeifer.


this error occur when the variable name is not string, in this line of driver.m file:

M_.params(i) = eval([‘pp.’ name]);

and the variable name is generated by another line of driver.m file:

name = deblank(M_.param_names(i,:));

when M_.param_names(i,:) is cell, the variable name would not be string.


You can set a breakpoint in this line of dynare.m:

evalin(‘base’,[fname ‘.driver’]);

then run your code. when it pause, open the corresponding driver.m file, and modify the name = deblank(M_.param_names(i,:)); to:

name = deblank(M_.param_names{i,:});

then save and continue. Dynare will finish its work.

@einheria As pointed out above, the reason is that Dynare moved from strings to cell arrays in version 4.6. That’s why I provided an updated version of the toolkit to account for that.

Bravo! It seems like I missed something important. Cos I just downloaded the latest version and encounter same problem, I thought your update wont fix it.

Thank you so much! I dont need to manully fix it now :smile: