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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
function [a_out, b_out]=dl(x)
% DL Mean of the diagonal line lengths and their distribution.
% A=DL(X) computes the mean of the length of the diagonal
% line structures in a recurrence plot.
%
% [A B]=DL(X) computes the mean A and the distribution of the
% length of the diagonal line structures, stored in B.
%
% See also CRQA, DET, TT.
% Copyright (c) 2001-2004 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))>100000 % this should speed up the routine; the value
% depends on the available memory
x2=uint8(x);
N=size(x2);
x3=zeros(2*N(2)+N(1),N(2));
x3(N(2)+1:N(2)+N(1),1:N(2))=x2;
N3=size(x3);
i2=repmat(((1:1+N(2))+N(1)+N(2))',1,N(2));
i4=i2+repmat((2*N(2)+N(1)+1)*[0:N(2)-1],size(i2,1),1);
i4(:,end)=[];
i4=reshape(i4,size(i4,1)*size(i4,2),1);
x3(i4)=[];
x3(end)=[];
x2=(reshape(x3,N(1)+N(2),N(2)))';
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
N=size(x);
% x3=zeros(2*N(2)+N(1),N(2));
% x3(N(2)+1:N(2)+N(1),1:N(2))=x;
% N3=size(x3);
%
% i2=repmat(((1:1+N(2))+N(1)+N(2))',1,N(2));
% i4=i2+repmat((2*N(2)+N(1)+1)*[0:N(2)-1],size(i2,1),1);
% i4(:,end)=[];
% i4=reshape(i4,size(i4,1)*size(i4,2),1);
% x3(i4)=[];
% x3(end)=[];
% x=(reshape(x3,N(1)+N(2),N(2)))';
%
% x(end+1,:)=0;
% for i1=-ceil(N(2)/2):ceil(N(2)/2); temp=diag(x,i1); X(1:length(temp),1+i1+ceil(N(2)/2))=temp;
% end, x=double(X);
x1=spdiags(x);
z=reshape(x1,size(x1,1)*size(x1,2),1);
z2(2:length(z)+1)=z;z2(1)=0;z2(end+1)=0;
z=diff(z2);
z0=find(z==1);
z1=find(z==-1);
end
if length(z0)>length(z1), z0(end)=[]; end
if length(z1)>length(z0), z1(end)=[]; end
if isempty(z0), z0=0; end
if isempty(z1), z1=0; 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
l=sort(z1-z0); %l(end)=[];
l1=l(find(l-1));
if nargout==2
b_out=zeros(length(l),1);
b_out=l';
end
if nargout>0
a_out=mean(l1);
else
mean(l1)
end
else
if nargout==2
b_out=NaN;
end
if nargout>0
a_out=NaN;
else
NaN
end
end
warning on