Matlab function that calls Dynare

I want to create a function that runs a dynare.mod file and uses the output for some of the variables within that function. But when running the debugmode in Matlab to trace the problem it seems like as soon as I enter the “function mode” it blocks Dynare from saving any of the output in Matlabs workspace and therefore the function says that the variable in question is missing. Does anyone know a work around for this problem?

Are you calling Dynare with the noclearall option?