I am trying to use DSGE models to create artificial data in order to build a hybrid model DSGE-VAR. Indeed, i need to construct observations with a size Ta = k*Tr. Tr represents a real observations size and k a weight that is given the prior information in our analysis. Nevertheless, when computing my programs, i encounter the following problem. If k is not an integer such as (1;2;3;…), my program can not run because Ta should be also an integer. So, my question is:

Can we use usual functions like “sqrt” or “floor” within macro-expression, to resolve my problem?

Sorry, but the preprocessor is for text operations. The expressions you create will not be parsed.
You can get around some of the restriction by directly using the expression for n:

test1=normrnd(0,0.0001,floor(@{poids}*@{j})),1);
But this only works for code parts interpreted by Matlab, which knows the floor()-command. It will fail with

periods 1:@{n};
Have you considered doing the first loop via Dynare and then manually iterating over perfect_foresight_setup and perfect_foresight_solver via a Matlab-script?

If I understand it correctly, you are using the macro-processor to loop over

where you change the number of periods. What you can do is run the mod-file once for the first step of the loop. Dynare will provide you with the code for this in the m-file. Then you can just take that piece of code and adjust it. If you provide me with a clean mod-file for the first step (i.e. without the macroprocessor stuff) and tell me what you are trying to do, I might be able to help you.

This seems to be buggy. Please do not rely on the output of arithmetic in define statements. We are investigating the issue. See github.com/DynareTeam/dynare/issues/1278