diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index 314940f2c5ad145b0368378bd98c4abdf600cc76..745ef536330b039e5a8de25dca8051cb08588c5b 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -863,7 +863,9 @@ if (any(bayestopt_.pshape  >0 ) & options_.mh_replic) | ...
   %% Here i discard first half of the draws:
   CutSample;
   %% Estimation of the marginal density from the Mh draws:
-  marginal = marginal_density;
+  if options_.mh_replic
+      marginal = marginal_density;
+  end
   %% 
   GetPosteriorParametersStatistics;
   PlotPosteriorDistributions;