From d657405d92bbfd7813699980e9c515de07f4711a Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 27 Mar 2013 12:26:08 +0100
Subject: [PATCH] Bugfix in correlation_mc_analysis

Closes #290 and makes #314 obsolete as we store both auto- and
cross-correlations
(manually cherry picked from commit f995f3da90c94d2f2179c3e075a89116b27720cc)
---
 doc/dynare.texi                  | 3 ++-
 matlab/correlation_mc_analysis.m | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/doc/dynare.texi b/doc/dynare.texi
index d17a9c9d2..18b7ad52e 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -4507,7 +4507,8 @@ where @var{THEORETICAL_MOMENT} is one of the following:
 Variance-covariance of endogenous variables
 
 @item correlation
-Autocorrelation of endogenous variables
+Auto- and cross-correlation of endogenous variables. Fields are vectors with correlations from 1 up to order @code{options_.ar}
+
 
 @item VarianceDecomposition
 Decomposition of variance@footnote{When the shocks are correlated, it
diff --git a/matlab/correlation_mc_analysis.m b/matlab/correlation_mc_analysis.m
index 6d66de9d9..41628b8ea 100644
--- a/matlab/correlation_mc_analysis.m
+++ b/matlab/correlation_mc_analysis.m
@@ -49,9 +49,9 @@ if isfield(oo_,[TYPE 'TheoreticalMoments'])
         eval(['temporary_structure = oo_.' TYPE 'TheoreticalMoments.dsge;'])
         if isfield(temporary_structure,'correlation')
             eval(['temporary_structure = oo_.' TYPE 'TheoreticalMoments.dsge.correlation.mean;'])
-            if isfield(temporary_structure,var1)
+            if isfield(temporary_structure,deblank(var1))
                 eval(['temporary_structure_1 = oo_.' TYPE 'TheoreticalMoments.dsge.correlation.mean.' var1 ';']) 
-                if isfield(temporary_structure_1,var2)
+                if isfield(temporary_structure_1,deblank(var2))
                     eval(['temporary_structure_2 = temporary_structure_1.' var2 ';'])
                     l1 = length(temporary_structure_2);
                     if l1<nar
-- 
GitLab