Pass a matlab string to a MACRO_VARIABLE

That’s because the command line treats xy as a string. Use

xy =pwd

eval(['dynare mainfile -Dpath="' xy '"'])

to construct the proper string substitutions.