Sorry I know questions of ''looping over parameters" have been raised over and over, but I still feel a little confused. For example, now I have the following fraction of codes. (If you need codes, I’ll attach them). In `exercise.m`

file:

```
global RHO_A RHO_R RHO_RF RHO_YF RHO_P RHO_Y RHO_E;
global params;
RHO_A = 0.9;
RHO_R = 0.0;
RHO_RF = 0.9;
RHO_YF = 0.9;
RHO_P = 1.5;
RHO_Y = 0.5;
RHO_E = 0.0;
params = [RHO_A; RHO_R; RHO_RF; RHO_YF; RHO_P; RHO_Y; RHO_E];
save parametervalues ...
RHO_A RHO_R RHO_RF RHO_YF RHO_P RHO_Y RHO_E;
save params;
dynare Loop.mod noclearall
```

In `Loop.mod`

,

```
load params;
set_param_value('RHO_A',RHO_A);
set_param_value('RHO_R',RHO_R);
set_param_value('RHO_RF',RHO_RF);
set_param_value('RHO_YF',RHO_YF);
set_param_value('RHO_P',RHO_P);
set_param_value('RHO_Y',RHO_Y);
set_param_value('RHO_E',RHO_E);
```

`Loop.mod`

makes me find the optimal value of some parameters, denoted as

RHO_R_opt, RHO_P_opt, RHO_Y_opt, RHO_E_opt

I compare them with the literature, and I confirm they are correct.

**Then I face the problem:**

I update values of some parameters as follows: (written in the same `exercise.m`

)

```
set_param_value('RHO_R',RHO_R_opt);
set_param_value('RHO_P',RHO_P_opt);
set_param_value('RHO_Y',RHO_Y_opt);
set_param_value('RHO_E',RHO_E_opt);
```

In the Workspace window, they are truly updated.

BUT, when I continue adding the commands in `exercise.m`

to show IRFs of the updated optimal model, (`Loop.mod`

and `optmodel.mod`

are almost identical, except the former has loops, the latter has updated some parameters)

```
dynare optmodel.mod noclearall
```

In the Workspace window, RHO_R, RHO_P, RHO_Y, RHO_E return to OLD values!!

BTW I try to append

```
for iter = 1:length(M_.params)
eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end
params = M_.params;
```

somewhere in `exercise.m`

, parameters still return OLD values after implementing `optmodel.mod`

.

How to update them correctly?