From f86b0a5ad6f0abee8239a01c0f5da7ea72be18ac Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Sun, 5 Jun 2016 20:15:55 +0200
Subject: [PATCH] Make dyn_forecast.m account for trend_coeffs saving
 coefficients for all variables

---
 matlab/dyn_forecast.m | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/matlab/dyn_forecast.m b/matlab/dyn_forecast.m
index 135e0eb9b3..8afc40f2bc 100644
--- a/matlab/dyn_forecast.m
+++ b/matlab/dyn_forecast.m
@@ -107,9 +107,10 @@ switch task
         trend_coeffs = [];
         for i=1:length(var_obs)
             tmp = strmatch(var_obs{i},endo_names(i_var,:),'exact');
+            trend_var_index=strmatch(var_obs{i},M.endo_names,'exact');
             if ~isempty(tmp)
                 i_var_obs = [ i_var_obs; tmp];
-                trend_coeffs = [trend_coeffs; oo.Smoother.TrendCoeffs(i)];
+                trend_coeffs = [trend_coeffs; oo.Smoother.TrendCoeffs(trend_var_index)];
             end
         end
         if ~isempty(trend_coeffs) 
-- 
GitLab