'simu' and other variables are only defined when nanmean(zb_post(i,j)) == 1. If that nanmean() is not equal to exactly 1, 'simu' and other variables are never defined. To fix that, define simu, mess, & reff when the nanmean is not equal to 1.
if nanmean(zb_post(i,j)) == 1
simu = squeeze(zb(end,i,:));
mess = squeeze(zb_post(i,:)).';
ref = squeeze(zb_ref(i,:)).';
else
simu = ???
mess = ???
ref = ???
end