From 389123d0b5fa2d738b88782bcbe873c4ad037f8b Mon Sep 17 00:00:00 2001
From: Marco Ratto <marco.ratto@jrc.ec.europa.eu>
Date: Thu, 16 Feb 2017 15:46:40 +0100
Subject: [PATCH] bug fixes.

---
 matlab/smoother2histval.m | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/matlab/smoother2histval.m b/matlab/smoother2histval.m
index 4319f50c60..225808c1ec 100644
--- a/matlab/smoother2histval.m
+++ b/matlab/smoother2histval.m
@@ -76,6 +76,14 @@ else
     post_metropolis = 0;
 end
 
+if post_metropolis
+    tmp = fieldnames(smoothedvars.Mean);
+    tmpexo = fieldnames(smoothedshocks.Mean);
+else
+    tmp = fieldnames(smoothedvars);
+    tmpexo = fieldnames(smoothedshocks);
+end
+
 % If post-Metropolis, select the parameter set
 if isempty(options_.parameter_set)
     if post_metropolis
@@ -113,11 +121,6 @@ else
 end
 
 % Determine number of periods
-if post_metropolis==2
-    tmp = fieldnames(smoothedvars.Mean);
-else
-    tmp = fieldnames(smoothedvars);
-end
 n = size(getfield(smoothedvars, tmp{1}));
 
 if n < M_.maximum_endo_lag
@@ -130,7 +133,7 @@ if isfield(opts, 'invars')
         invars = cellstr(invars);
     end
 else
-    invars = [fieldnames(smoothedvars); fieldnames(smoothedshocks)];
+    invars = [tmp; tmpexo];
 end
 
 if isfield(opts, 'period')
-- 
GitLab