From 328018f6dd28a4ba6462b765853f7b0f1b4b46ed Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Fri, 17 Sep 2021 14:42:44 +0200
Subject: [PATCH] smoother2histval.m: also set M_.exo_histval

(cherry picked from commit 62e80b0c07d14539f5bc515a3664131d1640926f)
---
 matlab/smoother2histval.m | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/matlab/smoother2histval.m b/matlab/smoother2histval.m
index 29791be1dd..c7502012e8 100644
--- a/matlab/smoother2histval.m
+++ b/matlab/smoother2histval.m
@@ -188,11 +188,16 @@ for i = 1:length(invars)
     
     v = s((period-M_.maximum_lag+1):period);
     if ~isfield(opts, 'outfile')
-        j = strmatch(outvars{i}, M_.endo_names, 'exact');
-        if isempty(j)
-            error(['smoother2histval: output variable ' outvars{i} ' does not exist.'])
-        else
-            M_.endo_histval(j, :) = v(k);
+        j_endo = strmatch(outvars{i}, M_.endo_names, 'exact');
+        if ~isempty(j_endo) 
+            M_.endo_histval(j_endo, :) = v;
+        end
+        j_exo = strmatch(outvars{i}, M_.exo_names, 'exact');
+        if ~isempty(j_exo)
+            M_.exo_histval(j_exo, :) = v;
+        end
+        if isempty(j_endo) && isempty(j_exo)
+            error(['smoother2histval: output variable ' outvars{i} ' does not exist.'])            
         end
     else
         data(:, i) = v';
-- 
GitLab