diff --git a/DynareFlex.ll b/DynareFlex.ll
index 8924d796614710fb5c62fcba5d70e5728e91b31e..8aea075968d2e01d31691580d838287216cecd6b 100644
--- a/DynareFlex.ll
+++ b/DynareFlex.ll
@@ -387,12 +387,17 @@ int sigma_e = 0;
   return token::QUOTED_STRING;
 }
 
- /* an instruction starting with a recognized symbol (which is not a modfile local variable)
-    is passed as NAME,
-    otherwise it is a native statement until the end of the line
+ /* An instruction starting with a recognized symbol (which is not a modfile local
+    or an unknown function) is passed as NAME, otherwise it is a native statement
+    until the end of the line.
+    We exclude modfile local vars because the user may want to modify their value
+    using a Matlab assignment statement.
+    We also exclude unknown functions because the user may have used a Matlab matrix
+    element in initval (in which case Dynare recognizes the matrix name as an unknown
+    function symbol), and may want to modify the matrix later with Matlab statements.
  */
 <INITIAL>[A-Za-z_][A-Za-z0-9_]* {
-  if (driver.symbol_exists_and_is_not_modfile_local_variable(yytext))
+  if (driver.symbol_exists_and_is_not_modfile_local_or_unknown_function(yytext))
     {
       BEGIN DYNARE_STATEMENT;
       yylval->string_val = new string(yytext);
diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 06b87379a48a7e2b24759d3fdfeb579bb26db21d..aa38e10b8bb481469a13325ebd7c91ae2c2e6edd 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -25,12 +25,14 @@
 #include "Statement.hh"
 
 bool
-ParsingDriver::symbol_exists_and_is_not_modfile_local_variable(const char *s)
+ParsingDriver::symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s)
 {
   if (!mod_file->symbol_table.exists(s))
     return false;
 
-  return(mod_file->symbol_table.getType(s) != eModFileLocalVariable);
+  SymbolType type = mod_file->symbol_table.getType(s);
+
+  return(type != eModFileLocalVariable && type != eUnknownFunction);
 }
 
 void
diff --git a/include/ParsingDriver.hh b/include/ParsingDriver.hh
index a752a867114a9ef9554659e3ba61342551b9f4de..7120acb8d79e083f51b637da602ce17f03ce7dab 100644
--- a/include/ParsingDriver.hh
+++ b/include/ParsingDriver.hh
@@ -162,7 +162,7 @@ public:
   void warning(const string &m);
 
   //! Check if a given symbol exists in the parsing context, and is not a mod file local variable
-  bool symbol_exists_and_is_not_modfile_local_variable(const char *s);
+  bool symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s);
   //! Sets mode of ModelTree class to use C output
   void use_dll();
   //! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in a C context