Macro variable and .mod inserted in .m

Dear all,

For some reasons, I included my .mod in a matlab file .m.
However in my .mod I use macro variables
(for instance I use @#define VARshock = 0 or 1 which I use with a if condition to define whether my shocks have AR or VAR structure).
But I would like to define the value of my macrovariable (o or 1) in the .m, i.e “decide” in the .m whether my shocks have a VAR structure or not, without having to open and modify the .mod file. How could I do that?

I hope my question is clear enough.

Thank you in advance,

best regards

Rudy

What you can do is write the definition statement

@#define VARshock = 0 into a txt file in your m-file using e.g.

var_shock_indicator=1; fid=fopen('par_def.txt','w+'); fprintf(fid,' @#define VARshock = %u \n',var_shock_indicator); fclose(fid)
Then include this file in your mod-file using

Dear Prof Pfeifer,

Thank you very much for your answer, your solution works well and it helped a lot!

(Just in case someone also want to use it, I had to write @#include “par_def.txt” - ie don’t forget to put the filename into quotation marks).

BR

Rudy