Skip to content
Snippets Groups Projects
Commit 39c5f2cf authored by marwan's avatar marwan
Browse files

includes also white vertical lines

parent 4805f042
No related branches found
No related tags found
No related merge requests found
function [a_out, b_out]=tt(x) function [a_out, b_out, c_out]=tt(x)
% TT Mean trapping time and its distribution. % TT Mean trapping time and its distribution.
% A=TT(X) computes the mean of the length of the vertical % A=TT(X) computes the mean of the length of the vertical
% line structures in a recurrence plot, so called trapping % line structures in a recurrence plot, so called trapping
...@@ -23,6 +23,9 @@ function [a_out, b_out]=tt(x) ...@@ -23,6 +23,9 @@ function [a_out, b_out]=tt(x)
% $Revision$ % $Revision$
% %
% $Log$ % $Log$
% Revision 3.3 2005/11/23 07:29:14 marwan
% help text updated
%
% Revision 3.2 2005/03/16 11:19:02 marwan % Revision 3.2 2005/03/16 11:19:02 marwan
% help text modified % help text modified
% %
...@@ -36,30 +39,25 @@ function [a_out, b_out]=tt(x) ...@@ -36,30 +39,25 @@ function [a_out, b_out]=tt(x)
% of the License, or any later version. % of the License, or any later version.
error(nargchk(1,1,nargin)); error(nargchk(1,1,nargin));
if nargout>2, error('Too many output arguments'), end if nargout>3, error('Too many output arguments'), end
%a_out = NaN; b_out = NaN; c_out = NaN;
warning off warning off
if any(x(:)) if any(x(:))
if min(size(x))>1000 % this should speed up the routine; the value
% depends on the available memory
x2=uint8(x); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x2(end+1,:)=0; % for black vertical lines
x=reshape(x2,size(x2,1)*size(x2,2),1); xb=double(x);
x2=x(2:end);x(end)=[]; xb(end+1,:)=0;xb=double(xb(:));
z0=find(x==0&x2==1); z=diff(xb);
z1=find(x2==0&x==1); z0=find(z==1); % begin of black sequence
z1=find(z==-1); % end of black sequence
else
x(end+1,:)=0;x=double(x);
z=diff(reshape(x,size(x,1)*size(x,2),1));
z0=find(~(z-1));
z1=find(~(z+1));
end
% measure the length of black lines
if z0(1)>z1(1) if z0(1)>z1(1)
z0(2:end+1)=z0(1:end);z0(1)=0; z0(2:end+1)=z0(1:end);z0(1)=0;
if length(z0)>length(z1) if length(z0)>length(z1)
...@@ -69,8 +67,43 @@ if any(x(:)) ...@@ -69,8 +67,43 @@ if any(x(:))
t=sort(z1-z0); t=sort(z1-z0);
t1=t(find(t-1)); t1=t(find(t-1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for white vertical lines
for i = 1:size(x,2)
i_ = find(x(:,i));
i1 = min(i_); i2 = max(i_);
x(1:i1,i) = 1;
x(i2:end,i) = 1;
end
xw=double(x); xw(end+1,:)=1;
zw=diff(xw(:));
z0w=find(zw==-1); % begin of white sequence
z1w=find(zw==1); % end of white sequence
% measure the length of white lines
if z0w(1)>z1w(1)
z0w(1)=[];
if length(z1w)>length(z0w)
z1w(end)=[];
end
end
if length(z1w)>length(z0w)
z0w=[1;z0w];
end
tw=sort(z1w-z0w);
t1w=tw(find(tw-1));
if nargout==2 if nargout==3
c_out=zeros(length(tw),1);
c_out=tw;
end
if nargout>=2
b_out=zeros(length(t),1); b_out=zeros(length(t),1);
b_out=t; b_out=t;
end end
...@@ -85,7 +118,11 @@ if any(x(:)) ...@@ -85,7 +118,11 @@ if any(x(:))
else else
if nargout==2 if nargout==3
c_out=NaN;
end
if nargout>=2
b_out=NaN; b_out=NaN;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment