diff --git a/crp.m b/crp.m
index b7460cd50b9cd41628abe2241f9fd88111ccf925..9ad81bdc9b49600fc8aba26197e19d74248485b1 100644
--- a/crp.m
+++ b/crp.m
@@ -38,7 +38,7 @@ function xout=crp(varargin)
 %      minnorm     - Minimum norm.
 %      nrmnorm     - Euclidean norm between normalized vectors
 %                    (all vectors have the length one).
-%      maxnorm     - Maximum norm, fixed recurrence rate.
+%      rr          - Maximum norm, fixed recurrence rate.
 %      fan         - Fixed amount of nearest neighbours.
 %      inter       - Interdependent neighbours.
 %      omatrix     - Order matrix.
@@ -84,6 +84,9 @@ function xout=crp(varargin)
 % $Revision$
 %
 % $Log$
+% Revision 5.16  2010/06/29 12:46:47  marwan
+% bug in checking the lengths of x and y
+%
 % Revision 5.15  2009/03/24 08:31:17  marwan
 % copyright address changed
 %
@@ -288,22 +291,27 @@ if isnumeric(varargin{1}) 		% read commandline input
          errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
          waitforbuttonpress
     end
+  % normalise the data   
   if size(x,2)>=2
      xscale=x(:,1); 
      if ~isempty(find(diff(xscale)<0)), error('First column of the first vector must be monotonically non-decreasing.'),end
-     if nonorm==1, x=(x(:,2)-mean(x(:,2)))/std(x(:,2)); else x=x(:,2); end
+     idx = find(~isinf(x(:,2)));
+     if nonorm==1, x=(x(:,2)-mean(x(idx,2)))/std(x(idx,2)); else x=x(:,2); end
   else
-     if nonorm==1, x=(x-mean(x))/std(x); end
+     idx = find(~isinf(x));
+     if nonorm==1, x=(x-mean(x(idx)))/std(x(idx)); end
      xscale=(1:length(x))'; 
   end
 
   if size(y,2)>=2
      yscale=y(:,1); 
      if ~isempty(find(diff(yscale)<0)), error('First column of the second vector must be monotonically non-decreasing.'),end
-     if nonorm==1, y=(y(:,2)-mean(y(:,2)))/std(y(:,2)); else y=y(:,2); end
+     idx = find(~isinf(y(:,2)));
+     if nonorm==1, y=(y(:,2)-mean(y(idx,2)))/std(y(idx,2)); else y=y(:,2); end
   else
-      if nonorm==1, y=(y-mean(y))/std(y); end
-      yscale=(1:length(y))';
+     idx = find(~isinf(y));
+     if nonorm==1, y=(y-mean(y(idx)))/std(y(idx)); end
+     yscale=(1:length(y))';
   end
   ds=eye(m);
   
@@ -692,7 +700,7 @@ switch(action)
       if check_stop(hCRP,hCtrl,nogui,obj), return, end
 
       set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')'),'String','Building CRP Matrix'),drawnow
-      X=(uint8(255*s/max(s(:)))<(255*e/max(s(:))))'; clear s s1 x1 y1 px py
+      X=uint8((s/max(s(:)))<(e/max(s(:))))'; clear s s1 x1 y1 px py
       matext=[num2str(round(100*e)/100) unit ' (normalized distance euclidean norm)'];
 
 
diff --git a/crp2.m b/crp2.m
index 2fdc261bf7993443f6ca8aca01ca156db63a341e..bb870f45962ffc3eff96dcd2d4f6e949f4c4b546 100644
--- a/crp2.m
+++ b/crp2.m
@@ -37,7 +37,7 @@ function xout=crp2(varargin)
 %      minnorm     - Minimum norm.
 %      nrmnorm     - Euclidean norm between normalized vectors
 %                    (all vectors have the length one).
-%      maxnorm     - Maximum norm, fixed recurrence rate.
+%      rr          - Maximum norm, fixed recurrence rate.
 %      fan         - Fixed amount of nearest neighbours.
 %      omatrix     - Order matrix (disabled).
 %      opattern    - Order patterns recurrence plot.
@@ -86,6 +86,9 @@ function xout=crp2(varargin)
 % $Revision$
 %
 % $Log$
+% Revision 5.18  2010/06/29 12:47:30  marwan
+% some minor bugs in output and test of time series lengths (of x and y)
+%
 % Revision 5.17  2009/03/24 08:31:17  marwan
 % copyright address changed
 %
@@ -295,19 +298,31 @@ if isnumeric(varargin{1}) 		% read commandline input
             'Either too much NaN or the number of columns in the vectors do not match.'])
   end
 
-    Nx=size(x,1); Ny=size(y,1);
-    NX=Nx-t*(m0-1);NY=Ny-t*(m0-1);
-    x0=zeros(Nx,m);y0=zeros(Ny,m);
-    x0(1:size(x,1),1:size(x,2))=x; 
-    y0(1:size(y,1),1:size(y,2))=y; 
-
-    if nonorm==1, 
-	 x=(x0-repmat(mean(x0),Nx,1))./repmat(std(x0),Nx,1);
-	 y=(y0-repmat(mean(y0),Ny,1))./repmat(std(y0),Ny,1);
-    end
+  Nx=size(x,1); Ny=size(y,1);
+  NX=Nx-t*(m0-1);NY=Ny-t*(m0-1);
+  x0=zeros(Nx,m);y0=zeros(Ny,m);
+  x0(1:size(x,1),1:size(x,2))=x; 
+  y0(1:size(y,1),1:size(y,2))=y; 
+
+  % normalise the data
+  if nonorm == 1,
+      for k = 1:size(x0,2)
+          idx = find(~isinf(x0(:,k)));
+          stdx = std(x0(idx,k));
+          meanx = mean(x0(idx,k));
+          x(:,k) = (x0(:,k) - meanx) / stdx;
+      end
+      for k = 1:size(y0,2)
+          idy = find(~isinf(x0(:,k)));
+          stdy = std(y0(idy,k));
+          meany = mean(y0(idy,k));
+          y(:,k) = (y0(:,k) - meany) / stdy;
+      end
+  end
 
   if ~isempty(find(isnan(x))), for k=1:size(x,2),  x(find(isnan(x(:,k))),:)=[]; end, end
   if ~isempty(find(isnan(y))), for k=1:size(y,2),  y(find(isnan(y(:,k))),:)=[]; end, end
+
   if size(x,1) < t*(m0-1)+1 | size(y,1) < t*(m0-1)+1
      error(['Too less data',10,...
             'Either too much NaN or the number of columns in the vectors do not match.'])
@@ -1118,7 +1133,7 @@ switch(action)
       if check_stop(hCRP,hCtrl,nogui,obj), return, end
 
       set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'String','Building CRP Matrix'),drawnow
-      X=reshape(uint8(255*s/max(s))<(255*e/max(s)),Ny,Nx); clear s x1 y1 
+      X=uint8(reshape((s/max(s))<(e/max(s)),Ny,Nx)); clear s x1 y1 
       matext=[num2str(round(100*e)/100) unit ' (normalized distance euclidean norm)'];
 
 
diff --git a/crp_big.m b/crp_big.m
index cb7643a8bcc79bf456e75babb0e126936c31f125..095e947fefff90f23c2b559229c24628c133a6c2 100644
--- a/crp_big.m
+++ b/crp_big.m
@@ -40,7 +40,7 @@ function xout=crp_big(varargin)
 %      minnorm     - Minimum norm.
 %      nrmnorm     - Euclidean norm between normalized vectors
 %                    (all vectors have the length one).
-%      maxnorm     - Maximum norm, fixed recurrence rate.
+%      rr          - Maximum norm, fixed recurrence rate.
 %      fan         - Fixed amount of nearest neighbours.
 %      inter       - Interdependent neighbours.
 %      omatrix     - Order matrix.
@@ -82,6 +82,9 @@ function xout=crp_big(varargin)
 % $Revision$
 %
 % $Log$
+% Revision 5.14  2010/06/29 12:48:16  marwan
+% bug in checking the lengths of x and y
+%
 % Revision 5.13  2009/03/24 08:31:17  marwan
 % copyright address changed
 %
@@ -278,21 +281,27 @@ if isnumeric(varargin{1})==1 		% read commandline input
          errordlg('The embedding vectors cannot be created. Dimension M and/ or delay T are to big. Please use smaller values.','Dimension/ delay to big')
          waitforbuttonpress
     end
+  % normalise the data   
   if size(x,2)>=2
      xscale=x(:,1); 
      if ~isempty(find(diff(xscale)<0)), error('First column of the first vector must be monotonically non-decreasing.'),end
-     if nonorm==1, x=(x(:,2)-mean(x(:,2)))/std(x(:,2)); else x=x(:,2); end
+     idx = find(~isinf(x(:,2)));
+     if nonorm==1, x=(x(:,2)-mean(x(idx,2)))/std(x(idx,2)); else x=x(:,2); end
   else
-     if nonorm==1, x=(x-mean(x))/std(x); end
+     idx = find(~isinf(x));
+     if nonorm==1, x=(x-mean(x(idx)))/std(x(idx)); end
      xscale=(1:length(x))'; 
   end
+
   if size(y,2)>=2
      yscale=y(:,1); 
      if ~isempty(find(diff(yscale)<0)), error('First column of the second vector must be monotonically non-decreasing.'),end
-     if nonorm==1, y=(y(:,2)-mean(y(:,2)))/std(y(:,2)); else y=y(:,2); end
+     idx = find(~isinf(y(:,2)));
+     if nonorm==1, y=(y(:,2)-mean(y(idx,2)))/std(y(idx,2)); else y=y(:,2); end
   else
-      if nonorm==1, y=(y-mean(y))/std(y); end
-      yscale=(1:length(y))';
+     idx = find(~isinf(y));
+     if nonorm==1, y=(y-mean(y(idx)))/std(y(idx)); end
+     yscale=(1:length(y))';
   end
   ds=eye(m);
 
@@ -704,7 +713,7 @@ switch(action)
                           matext=[num2str(round(100*e)/100) unit ' (fixed distance minimum norm)'];
                       end
 
-                      X1=255*s/max(s(:))<(255*e/max(s(:)));
+                      X1=s/max(s(:))<(e/max(s(:)));
                       X0=(uint8(X1))'; clear s s1 x1 y1 px py X1
                       X(1+Ny2*(j-1):Ny2+Ny2*(j-1),1+Nx2*(i-1):Nx2+Nx2*(i-1))=X0;
                       X(NY0+1:end,:)=[];
@@ -731,7 +740,7 @@ switch(action)
                       s1 = px(:,ones(1,NY),:) - py(ones(1,NX),:,:);
                       s = sqrt(sum(s1.^2, 3));
 
-                      X0=(uint8(255*s/max(s(:)))<(255*e/max(s(:))))'; clear s s1 x1 y1 px py
+                      X0=uint8((s/max(s(:)))<(e/max(s(:))))'; clear s s1 x1 y1 px py
 
                       X(1+Ny2*(j-1):Ny2+Ny2*(j-1),1+Nx2*(i-1):Nx2+Nx2*(i-1))=X0;
                       X(NY0+1:end,:)=[];