I’m trying to do a surface analysis of the loss function of a DSGE model.
I have tried several ways, but I cannot find the solution, I would like to make a graphic similar to the one attached below.
in my case the surface should be made up of the inflation coefficient, the output gap coefficient and the loss function.
I hope you give me some hints.

you need mesh command, but be careful of your order, that is,
if L(phiP, phiX) is taken from Ls(phiPs, phiXs), then you should type

mesh(phiXs,phiPs,Ls);

instead of

mesh(phiPs,phiXs,Ls);

The other error dynare reports is BK condition violated, if you temporarily erase noprint in your stoch_simul. You need to quantify your phiP greater than 1. Here I set phiPs to start from 1.1

So I add and modify some codes as follows:

phiPs = 1.1:0.5:3.1;
phiXs = 0:0.5:3;
Ls = -Inf*ones(length(phiPs),length(phiXs));
for ii = 1:length(phiPs)
phiP = phiPs(ii);
for jj = 1:length(phiXs)
phiX = phiXs(jj);
stoch_simul(order=1, nograph, noprint)
x y bl piD pi pD p ti er Der i il rR M a g iS pS;

Then I slightly rearrange some parts of your codes, to let Dynare compute moments in each iteration. Your original codes may not work very well for the mission of “looping over parameters”.