From 797807081463ee21c6032376ce80ac36a29a81eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Fri, 3 Feb 2012 12:52:37 +0100
Subject: [PATCH] Fixed bug.

---
 matlab/ep/extended_path.m | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/matlab/ep/extended_path.m b/matlab/ep/extended_path.m
index 57e77233ee..9e02d4a5f9 100644
--- a/matlab/ep/extended_path.m
+++ b/matlab/ep/extended_path.m
@@ -251,8 +251,10 @@ while (t<sample_size)
             % Test if periods is big enough. The variable delta measures the maximum absolute variation during
             % the last periods of the simulated path. This variation has to be close to zero (because the
             % economy is assumed to be in the steady state at the end of the simulated path).
-            delta = max(max(abs(tmp(:,end-options_.ep.lp:end)-tmp(:,end-options_.ep.lp-1:end-1))));
-            if ~increase_periods &&  delta<options_.dynatol.x
+            if info.convergence
+                delta = max(max(abs(tmp(:,end-options_.ep.lp:end)-tmp(:,end-options_.ep.lp-1:end-1))));
+            end
+            if info.convergence && ~increase_periods &&  delta<options_.dynatol.x
                 % Exit from the while loop (the number of periods is big enough).
                 break
             else
-- 
GitLab