Looping over ramsey_model and not just parameters in matlab file

I have a question regarding looping over parameters when using ramsey optimal policy. I implemented the following approach to loop over the parameters after the dynare file calls ramsey_model():

first_time = 1;
results_cell = cell(1,length(paramS));
for i = 0:length(paramS)
    if first_time
        dynare ramseyModel.mod
        first_time=0;
    else
        set_param_value(param,paramS(i));
        try
            perfect_foresight_setup;
            perfect_foresight_solver;
            if oo_.deterministic_simulation.status
                results_cell{i} = oo_;
            else
                results_cell{i} = NaN;
                disp("Computation fails for " + param + " = " + string(paramS(i)));
            end
        catch
            results_cell{i} = NaN;
            disp("Computation fails for " + param + " = " + string(paramS(i)));
        end
    end
end

It works so far, but this approach only loops over parameters after the ramsey_model is constructed. I want to loop over ramsey_model, so that optimal policy is constructed under different parametrizations. Is there a way to achieve this?

What exactly do you mean with

? What are you trying to do?