From 1898a1295a0d225fcfd68d3b836d971b4d61eb9b Mon Sep 17 00:00:00 2001
From: marwan <>
Date: Tue, 24 Jun 2008 14:11:55 +0000
Subject: [PATCH] Including of a abort condition in order to avoid infinite
 loops.

---
 recons.m | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/recons.m b/recons.m
index 3ce53b6..2cd16f7 100644
--- a/recons.m
+++ b/recons.m
@@ -1,4 +1,4 @@
-function xout=recons(varargin)
+function varargout=recons(varargin)
 %RECONS   Reconstruct a time series from a recurrence plot.
 %    Y = RECONS(X) reconstructs a time series Y from the 
 %    recurrence plot in the matrix X.
@@ -25,6 +25,9 @@ function xout=recons(varargin)
 % $Revision$
 %
 % $Log$
+% Revision 5.1  2008/01/25 12:47:25  marwan
+% initial import
+%
 %
 %
 %
@@ -36,7 +39,7 @@ function xout=recons(varargin)
 % of the License, or any later version.
 
 
-errcode = 0;
+errcode = 0; %xout = [];
 error(nargchk(1,2,nargin));
 if nargout>1, error('Too many output arguments'), end
 
@@ -137,6 +140,15 @@ while min(NN(:)) < maxN
     kold = k;
     k=kneu;
     r = [r; k]; % add the new found index to the rank order vector
+    if length(r) > N(1) + 1
+        delete(h_waitbar)
+        disp(['Critical abort. Could not find enough corresponding neigbours.',10,'Perhaps the recurrence threshold is too small.'])
+        if nargout
+            varargout{1} = NaN;
+        end
+        return
+    end
+    
 end
 
 errcode = 6;
@@ -163,7 +175,7 @@ delete(h_waitbar)
 errcode = 8;
 
 if nargout
-    xout = xneu;
+    varargout{1} = xneu;
 else
     xneu
 end
@@ -220,7 +232,7 @@ catch
     disp('   Thank you for your assistance.')
     warning('on')
   end
-  try, set(0,props.root), end
+  try, set(0,props.root), delete(h_waitbar), end
   set(0,'ShowHidden','Off')
   return
 end
-- 
GitLab