You need to sign in or sign up before continuing.
Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function [a_out, b_out]=tt(x)
% TT Mean trapping time and its distribution.
% A=TT(X) computes the mean of the length of the vertical
% line structures in a recurrence plot, so called trapping
% time TT.
%
% [A B]=TT(X) computes the TT and the distribution of the
% length of the vertical line structures, stored in B.
%
% See also CRQA, CRQAPLOT, DL.
% Copyright (c) 2001-2003 by AMRON
% Norbert Marwan, Potsdam University, Germany
% http://www.agnld.uni-potsdam.de
%
% $Date$
% $Revision$
%
% $Log$
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or any later version.
error(nargchk(1,1,nargin));
if nargout>2, error('Too many output arguments'), end
warning off
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;
x=reshape(x2,size(x2,1)*size(x2,2),1);
x2=x(2:end);x(end)=[];
z0=find(x==0&x2==1);
z1=find(x2==0&x==1);
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
if z0(1)>z1(1)
z0(2:end+1)=z0(1:end);z0(1)=0;
if length(z0)>length(z1)
z0(end)=[];
end
end
t=sort(z1-z0);
t1=t(find(t-1));
if nargout==2
b_out=zeros(length(t),1);
b_out=t;
end
if nargout>0
if isempty(t1), a_out=0;
else, a_out=mean(t1);
end
else
mean(t1)
end
else
if nargout==2
b_out=NaN;
end
if nargout>0
a_out=NaN;
else
NaN
end
end
warning on