Newer
Older
function xout=crp2(varargin)
%CRP2 Creates a cross recurrence plot/ recurrence plot and the LOS.
% CRP2(X [,Y [,param1,param2,...]) creates a cross recurrence
% plot/ recurrence plot from the embedding vectors X and Y.
% Results can be stored into the workspace. Further it
% is possible to estimate the line of synchronization (LOS)
% in order to get the nonparametric time-relationship between
% the two considered systems.
%
% R=CRP2(X,M2,T,E) uses the additionally dimension M2, delay T
% and the size of neighbourhood E and creates a recurrence
% plot of X.
%
% R=CRP2(X,Y,'distance','nonormalize') creates a
% distance coded matrix plot without normalization
% of the data.
%
% Allows to change the parameters interactively by
% using a GUI.
%
% The embedding dimension M is given by the size of the
% N x M matrix X and Y; if the matrix Y is not specified,
% a simple recurrence plot is created.
%
% Parameters: additionally dimension M2, delay T and the
% size of neighbourhood E are the first three numbers
% after the data series; further parameters can be used
% to switch between various methods of finding the
% neighbours of the phasespace trajectory, to suppress
% the normalization of the data and to suppress the
% GUI (useful in order to use this programme by other
% programmes).
%
% Methods of finding the neighbours.
% maxnorm - Maximum norm.
% euclidean - Euclidean norm.
% minnorm - Minimum norm.
% nrmnorm - Euclidean norm between normalized vectors
% (all vectors have the length one).
% rr - Maximum norm, fixed recurrence rate.
% omatrix - Order matrix (disabled).
% opattern - Order patterns recurrence plot.
% distance - Distance coded matrix (global CRP, Euclidean norm).
%
% Normalization of the data series.
% normalize - Normalization of the data.
% nonormalize - No normalization of the data.
%
% Suppressing the GUI.
% gui - Creates the GUI and the output plot.
% nogui - Suppresses the GUI and the output plot.
% silent - Suppresses all output.
%
% Parameters not needed to be specified.
%
% Current limitation: for higher speed in
% output the whole matrix of the recurrence
% plot is in the work space - this limits
% the application of long data series.
%
% Examples: a = sin((1:1000) * 2 * pi/200); % pendulum's location vector
% b = cos((1:1000) * 2 * pi/200); % pendulum's velocity vector
% plot(a,b,'.')
% crp2(a(1:500),b(1:500),'nonorm','euclidean')
%
% b = sin(.01 * ([1:1000] * 2 * pi/67) .^2);
% See also CRP, CRP_BIG, JRP, TAUCRP and TRACKPLOT.
%
% References:
% Marwan, N., Thiel, M., Nowaczyk, N.:
% Cross Recurrence Plot Based Synchronization of Time Series,
% Nonlin. Proc. Geophys., 9, 2002.
% Copyright (c) 2008-2009
% Norbert Marwan, Potsdam Institute for Climate Impact Research, Germany
% http://www.pik-potsdam.de
%
% Copyright (c) 1998-2008
% Norbert Marwan, Potsdam University, Germany
% http://www.agnld.uni-potsdam.de
%
% $Date$
% $Revision$
%
% $Log$
% Revision 5.19 2012/10/22 14:18:33 marwan
% bug fix: normalisation of data when data contains Inf
%
% 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
%
% Revision 5.16 2008/07/02 11:59:22 marwan
% new norms: DTW and Levenshtein
% bug fix for logical data vectors
%
% Revision 5.15 2008/04/29 14:52:01 marwan
% levenshtein and DTW distance added
%
% Revision 5.14 2007/07/18 17:18:44 marwan
% integer values in the arguments supported
%
% Revision 5.13 2007/05/15 17:33:13 marwan
% new neighbourhood criterion: fixed RR
%
% Revision 5.12 2007/05/15 16:00:38 marwan
% minor change in outfit
%
% Revision 5.11 2007/03/29 13:17:51 marwan
% uint8 of order patterns and order matrix
%
% Revision 5.10 2006/10/24 14:16:16 marwan
% minor change: sigma in title line of RP shown only for normalised data
%
% Revision 5.9 2006/03/29 13:07:55 marwan
% problems regarding OPRPs and embedding resolved
%
% Revision 5.8 2006/02/14 11:44:50 marwan
% bug in plugin-call (dim and delay) resolved
%
% Revision 5.7 2006/02/06 15:12:46 marwan
% bug in multi-dimensional embedding solved
%
% Revision 5.6 2006/02/06 13:46:17 marwan
% plugin for order patterns recurrence plots supported
%
% Revision 5.5 2005/11/23 07:30:30 marwan
% modified interdependent algorithm
% bug in showing RP fixed
%
% Revision 5.4 2005/11/09 08:58:13 marwan
% bug fix in interdependent neighbours method
%
% Revision 5.3 2005/09/02 08:02:57 marwan
% line fitting algorithm improved (linear interpolation between set points)
%
% Revision 5.2 2005/04/15 09:02:32 marwan
% minor bugfix in plugin section
%
% Revision 5.1 2005/04/08 09:52:27 marwan
% plugin added
%
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
% Revision 4.8.1.7.2.1 2005/04/08 09:22:13 marwan
% Included plugin
%
% Revision 4.8.1.7 2005/04/06 12:57:50 marwan
% small deviation in threshold application fixed
%
% Revision 4.8.1.6 2005/03/16 12:21:54 marwan
% add hint in help text for joint recurrence plots
%
% Revision 4.8.1.5 2005/03/16 11:19:02 marwan
% help text modified
%
% Revision 4.8.1.4 2004/12/23 07:49:03 marwan
% bug in order patterns RP fixed (empty order patterns)
%
% Revision 4.8.1.3 2004/12/02 13:18:30 marwan
% bug due to missing variable
%
% Revision 4.8.1.2 2004/11/15 12:52:34 marwan
% bug fix in choice of neighbourhood (enabling and disabling parameters)
%
% Revision 4.8.1.1 2004/11/12 08:39:02 marwan
% bug fix in order patterns representation
%
% Revision 4.8 2004/11/11 12:18:12 marwan
% order patterns recurrence plot added
%
% Revision 4.7 2004/11/10 07:04:40 marwan
% initial import
%
%
% This program is part of the new generation XXII series.
%
% 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.
warning off
global errcode props nonorm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% programme properties
errcode=0;
init_properties
hCRP=[];hCtrl=[];nogui=[];obj=[];mflag=[];
set(0,'ShowHidden','On')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check and read the input
error(nargchk(1,9,nargin));
if nargout>1, error('Too many output arguments'), end
check_meth={'ma','eu','mi','nr','rr','fa','in','om','op','le','dt','di'}; % maxnorm, euclidean, nrmnorm, fan, distance
check_norm={'non','nor'}; % nonormalize, normalize
check_gui={'gui','nog','sil'}; % gui, nogui, silent
% transform any int to double
intclasses = {'uint8';'uint16';'uint32';'uint64';'int8';'int16';'int32';'int64';'logical'};
flagClass = [];
for i = 1:length(intclasses)
i_int=find(cellfun('isclass',varargin,intclasses{i}));
if ~isempty(i_int)
for j = 1:length(i_int)
varargin{i_int(j)} = double(varargin{i_int(j)});
end
if ~isempty(flagClass)
disp(['Warning: Input arguments at position [',num2str(flagClass'),'] contain integer values']);
disp(['(now converted to double).'])
end
if isnumeric(varargin{1}) % read commandline input
varargin{9}=[];
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
i_double=find(cellfun('isclass',varargin,'double'));
i_char=find(cellfun('isclass',varargin,'char'));
% check the text input parameters for method, gui and normalization
temp_meth=0;
temp_norm=0;
temp_gui=0;
if ~isempty(i_char)
for i=1:length(i_char),
varargin{i_char(i)}(4)='0';
temp_meth=temp_meth+strcmpi(varargin{i_char(i)}(1:2),check_meth');
temp_norm=temp_norm+strcmpi(varargin{i_char(i)}(1:3),check_norm');
temp_gui=temp_gui+strcmpi(varargin{i_char(i)}(1:3),check_gui');
end
method=min(find(temp_meth));
nonorm=min(find(temp_norm))-1;
nogui=min(find(temp_gui))-1;
if isempty(method), method=1; end
if isempty(nonorm), nonorm=1; end
if isempty(nogui), nogui=0; end
if method>length(check_meth), method=length(check_meth); end
if nonorm>1, nonorm=1; end
if nogui>2, nogui=2; end
else
method=1; nonorm=1; nogui=0;
end
if nogui==0 & nargout>0, nogui=1; end
% get the parameters for creating RP
if max(size(varargin{1}))<=3
error('To less values in data X.')
end
x=double(varargin{1});
if isempty(varargin{2}) | ~isnumeric(varargin{2}), y=x; else
y=double(varargin{2}); end
if (isnumeric(varargin{2}) & max(size(varargin{2}))==1) | ~isnumeric(varargin{2})
y=x;
if ~isempty(varargin{i_double(2)}), m0=varargin{i_double(2)}(1); else m0=1; end
if ~isempty(varargin{i_double(3)}), t=varargin{i_double(3)}(1); else t=1; end
if ~isempty(varargin{i_double(4)}), e=varargin{i_double(4)}(1); else e=.1; end
else
if ~isempty(varargin{i_double(3)}), m0=varargin{i_double(3)}(1); else m0=1; end
if ~isempty(varargin{i_double(4)}), t=varargin{i_double(4)}(1); else t=1; end
if ~isempty(varargin{i_double(5)}), e=varargin{i_double(5)}(1); else e=.1; end
end
t=round(t); m0=round(m0); mflag=method;
if e<0, e=1; disp('Warning: The threshold size E cannot be negative and is now set to 1.'), end
if t<1, t=1; disp('Warning: The delay T cannot be smaller than one and is now set to 1.'), end
if m0 < 1, m0 = 1; end
if t < 1, t = 1; end
if size(x,1)==1, x=x'; end, if size(y,1)==1, y=y'; end
m=max([size(x,2) size(y,2)]);
m0=1;
error(['The neighbourhood criterion ''Oder matrix''',10,'is not implemented - use crp or crp_big instead.'])
end
m0=2;
disp(['Warning: For order patterns recurrence plots the dimension must',10,...
'be larger than one. ',...
'Embedding dimension is set to ',num2str(m0),'.'])
end
action='init';
if ~isempty(find(isnan(x)))
disp('NaN detected (in first variable) - will be cleared.')
for k=1:size(x,2), x(find(isnan(x(:,k))),:)=[]; end
end
if ~isempty(find(isnan(y)))
disp('NaN detected (in second variable) - will be cleared.')
for k=1:size(y,2), y(find(isnan(y(:,k))),:)=[]; end
end
if size(x,1) < t*(m-1)+1 | size(y,1) < t*(m-1)+1
% error(['Too less data',10,...
% 'Either too much NaN or the number of columns in the vectors do not match.'])
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.'])
end
if(size(x,2) ~= size(y,2))
error(['Matrix dimensions must agree.'])
end
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
else % read input from the GUI
action=varargin{1};
nogui=0;
h=get(gcf,'Name');h=h(findstr(h,'(')+1:findstr(h,')')-1);
hCRP=findobj('Name',['Cross Recurrence Plot (' h ')']);
hCtrl=findobj('Name',['Control (' h ')']);
h=str2num(h);
xshuttle=get(findobj('Parent',hCRP,'Tag','DataPlot2'),'UserData');
if ~isempty(xshuttle)
x=xshuttle(:,2:end);
yshuttle=get(findobj('Parent',hCRP,'Tag','DataPlot1'),'UserData');
y=yshuttle(:,2:end);
if ~isempty(hCtrl)
if get(findobj('Tag','Unthresh','Parent',hCtrl),'Value')
mflag=length(check_meth);
else
mflag=get(findobj('Tag','Method','Parent',hCtrl),'Value');
end
m=size(x,2);
m0=get(findobj('Tag','Dim0','Parent',hCtrl),'Value');
t=str2num(get(findobj('Tag','Delay','Parent',hCtrl),'String'));
e=str2num(get(findobj('Tag','Size','Parent',hCtrl),'String'));
if e<0, e=1;
errordlg('The threshold size E cannot be negative.','Threshold size to small')
waitforbuttonpress
set(findobj('Tag','Size','Parent',hCtrl),'String','1')
action='';
end
if t<1, t=1;
errordlg('The delay T cannot be smaller than one.','Delay to small')
waitforbuttonpress
set(findobj('Tag','Delay','Parent',hCtrl),'String','1')
action='';
end
ds = get(findobj('Tag','DimEx','Parent',hCtrl),'UserData');
if mflag==7 | mflag==8 | mflag==length(check_meth)
set(findobj('Tag','Size','Parent',hCtrl),'enable','off');
set(findobj('Tag','Sizetext','Parent',hCtrl),'enable','off');
else
set(findobj('Tag','Size','Parent',hCtrl),'enable','on');
set(findobj('Tag','Sizetext','Parent',hCtrl),'enable','on');
end
nonorm = get(findobj('Tag','nonorm','Parent',hCtrl),'UserData');
if mflag==8 & (m * m0) == 1,
m0=2;
errordlg(['For order patterns recurrence plots the',10,'dimension must be larger than one.'],'Dimension too small')
set(findobj('Tag','Dim0','Parent',hCtrl),'Value',m0)
NX=Nx-t*(m-1);NY=Ny-t*(m-1);
xscale=1:Nx; yscale=1:Ny;
if (NX<1 | NY<1) & strcmpi(action,'apply');
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
action='';
end
end
end
temp=get(findobj('Tag','fixp','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'XData');
if ~isempty(temp)
for i=1:length(temp), if iscell(temp), fixp(i,1)=temp{i}; else, fixp(i,1)=temp(i); end, end
temp=get(findobj('Tag','fixp','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'YData');
for i=1:length(temp), if iscell(temp), fixp(i,2)=temp{i}; else, fixp(i,2)=temp(i); end, end
fixp = sortrows(fixp,1);
else
fixp=[];
end
clear xshuttle yshuttle temp
cm_old=get(hCRP,'Colormap');
cm=[{hsv(256)}; {hot(256)}; {gray(256)};...
{french(256)}; {bone(256)}; {copper(256)}; {pink(256)};...
{flag(256)}; {lines(256)}; {colorcube(256)};...
{jet(256)}; {prism(256)}; {cool(256)};...
{autumn(256)}; {spring(256)}; {winter(256)};...
{summer(256)}; {flipud(gray(2))}; {flipud(cm_old)}];
if isempty(findobj('Tag','CRPFig')) & nogui==0
action='init';
end
end
h_meth = findobj('Tag','Method','Parent',hCtrl);
warndlg(['The neighbourhood criterion ''Interdependent''',10,'is not implemented - use crp or crp_big instead.'],'Neighbourhood');
waitforbuttonpress
if ~isempty(h_meth)
set(h_meth,'value',mflag)
end
warndlg(['The neighbourhood criterion ''Oder matrix''',10,'is not implemented - use crp or crp_big instead.'],'Neighbourhood');
waitforbuttonpress
if ~isempty(h_meth)
set(h_meth,'value',mflag)
end
set(findobj('Tag','Size','Parent',hCtrl),'enable','on');
set(findobj('Tag','Sizetext','Parent',hCtrl),'enable','on');
end
method=mflag;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% splash the GPL
splash_gpl('crp')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nogui
if nogui>0
hCRP=9999;
if nogui~=2
tx(5)={'maximum norm fixed RR'};
tx(6)={'fixed amount of nearest neighbours'};
tx(7)={'interdependent neighbours'};
tx(8)={'order matrix'};
tx(9)={'order pattern'};
tx(10)={'distance plot'};
tx(11)={'distance plot'};
tx(12)={'distance plot'};
disp(['use method: ', char(tx(method))]);
if nonorm==1, disp('normalize data'); else disp('do not normalize data'); end
end
action='compute';
if (NX<1 | NY<1)
disp('Warning: The embedding vectors cannot be created.')
disp('Dimension M and/ or delay T are to big. Please use smaller values.')
action='';
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% switch routines
switch(action)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% initialization
case 'init'
errcode=1;
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
yshuttle(:,2:size(y,2)+1)=y;
ds=eye(m);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% create GUI
errcode=2;
scr=get(0,'ScreenSize');
root_ud=get(0,'UserData');
if isstruct(root_ud)
if isfield(root_ud,'crp')
if ~isempty(root_ud.crp)
root_ud.crp=[root_ud.crp max(root_ud.crp)+1];
else
root_ud.crp=1;
end
h=num2str(root_ud.crp(end));
else
root_ud.crp=1;
h=num2str(1);
end
else
root_ud.old=root_ud;
root_ud.crp=1;
h=num2str(1);
end
set(0,'UserData',root_ud)
%%%%%%%%%%%%%%%%% CRP Figure
[h_axes,h_fig]=create_CRPfig(h,xshuttle,yshuttle);
h0=uicontextmenu('Parent',h_fig);
set(h_axes,'UIContextMenu',h0)
h2=line([],[],[],'Parent',h_axes,'visible','off','Tag','Diagonal','color',[1 0 0],...
'LineWidth',1);
uimenu(h0, 'Label', 'Set Point', 'Callback', 'crp2 LOSset')
%%%%%%%%%%%%%%%%% Control Figure
errcode=3;
h9=figure('Tag','CRPFig',... % Control Figure
'Color',[0.8 0.8 0.8], ...
'Position',[5*scr(3)/8+10 scr(4)/8 1*scr(3)/6 3*scr(4)/4 ],...
'NumberTitle','off',...
'Name',['Control (' h ')'],...
'MenuBar','None',...
'DeleteFcn','crp2 handlevisON',...
'Resize','Off');
set(h9,props.window,'Units','Norm')
h0=uicontrol(props.frame, ... % Frame Embedding
'Units','Normalized',...
'UserData',nonorm, ...
'Tag','nonorm', ...
'Position',[.1 .647 .8 .323]);
h0=uicontrol(props.text,... % Text Embedding
'Units','Normalized', ...
'FontAngle','italic', ...
'Position',[.12 .939 .6 .02], ...
'String','Embedding');
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
h0=uicontrol(props.text,... % Text Dimension
'Units','Normalized',...
'String','Dimension:',...
'Position',[.16 .905 .35 .02]);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
if method==8, set(h0,'Enable','Off'); end
h0=uicontrol(props.text,... % Text Dimensionvalue
'Units','Normalized',...
'Tag','Dim',...
'String',['x ',num2str(m)],...
'ToolTip','Embedding dimension.');
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
if method==8, set(h0,'Enable','Off'); end
h0=uicontrol(props.popup,... % Input Dimensionfactor
'Units','Normalized',...
'Tag','Dim0',...
'String','1|2|3|4',...
'Position',[.54 .91 .18 .026], ...
'Value',m0,...
'Callback','crp2 dimfit',...
'ToolTip','Select the embedding dimensionfactor.');
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
if method==8, set(h0,'Enable','Off'); end
h0=uicontrol(props.text,... % Text Delay
'Units','Normalized',...
'String','Delay:',...
'Position',[.16 .862 .35 .02]);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
if method==8, set(h0,'Enable','Off'); end
h0=uicontrol(props.edit,... % Input Delay
'Units','Normalized',...
'Tag','Delay',...
'String',t,...
'Position',[.54 .866 .279 .026],...
'ToolTip','Insert the embedding delay time.');
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
if m0==1;
set(h0,'Enable','off')
end
if method==8, set(h0,'Enable','Off'); end
h0=uicontrol(props.text,... % Text Vector Excluding
'Units','Normalized',...
'String','Vector Excluding:',...
'Position',[.16 .826 .6 .02], ...
'Tag','DimEx',...
'UserData', ds);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
for i=1:3, for j=1:4 % Input Vector Excluding
h0 = uicontrol(props.button,'Units','normalized', ...
'Callback','crp2 exclude', ...
'Position',[.18+(j-1)*0.167 0.798-(i-1)*0.034 .14 0.028], ...
'String',(i-1)*4+j, ...
'ToolTip','Exclude this vector.',...
'Tag',['DimShift' num2str((i-1)*4+j)]);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
end, end
for i=1:12
if i>m, set(findobj('Tag',['DimShift' num2str(i)]), 'Enable', 'off');
else, set(findobj('Tag',['DimShift' num2str(i)]), 'Enable', 'on'); end
end
h0=uicontrol(props.text,... % Text Copyright
'Units','Normalized',...
'HorizontalAlignment','center',...
'Position',[.15 .65 .7 .06]);
h1=textwrap(h0,{[char(169),' AGNLD'],'University of Potsdam','1998-2007'});
set(h0,'String',h1)
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
h0=uicontrol(props.frame, ... % Frame Neighbourhood
'Units','Normalized',...
'Position',[.1 .449 .8 .18]);
h0=uicontrol(props.text,... % Text Neighbourhood
'Units','Normalized',...
'FontAngle','italic', ...
'String','Neighbourhood',...
'Position',[.12 .598 .6 .02]);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
h0=uicontrol(props.checkbox, ... % Button Unthresholded
'Units','Normalized',...
'Position',[.16 .555 .51 .032], ...
'String','Unthresholded', ...
'CallBack','crp2 unthresh',...
'Tag','Unthresh',...
'ToolTip','Switch between thresholded and unthresholded CRP.' );
if method==8 | method==9, set(h0,'Enable','Off'); end
h1=uicontrol(props.popup, ... % Button Unthresholded Scale
'Units','Normalized',...
'Position',[.69 .555 .14 .032], ...
'String','1|1/2|1/4|1/6|1/8', ...
'Value',1,...
'CallBack','crp2 log',...
'Enable','off',...
'Tag','Log',...
'ToolTip','Switch between various scaled CRP.' );
h2=uicontrol(props.popup,... % Input Neighbourhood Method
'Units','Normalized',...
'String','Maximum Norm|Euclidean Norm|Minimum Norm|Normalized Norm|Fixed RR|Fixed Amount|Interdependent|Order Matrix|Order Pattern|Levenshtein|DTW',...
'Position',[.16 .509 .67 .032],...
'CallBack','crp2 unthresh',...
'Tag','Method',...
'ToolTip','Select the method of finding neighbours.');
if method==12, set(h2,'Enable','Off'); else, set(h2,'Value',method); end
h0=uicontrol(props.text,... % Text Threshold
'Units','Normalized',...
'Tag','Sizetext',...
'String','Threshold:',...
'Position',[.16 .462 .35 .02]);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
if method==12 | method==9, set(h0,'Enable','Off'); end
h0=uicontrol(props.edit,... % Input Threshold
'Units','Normalized',...
'Tag','Size',...
'Position',[.58 .466 .249 .026],...
'HorizontalAlignment', 'right',...
'String',e,...
'ToolTip','Insert the size of neighbourhood.' );
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
if method==12 | method==9, set(h0,'Enable','Off'); end
dark_factor=.86;
h0=uicontrol(props.frame,'BackgroundColor',dark_factor*props.frame.BackgroundColor, ... % Frame LOSsearch
'Units','Normalized',...
'Position',[.1 .212 .8 .22]);
h0=uicontrol(props.text,... % Text LOSsearch
'Units','Normalized',...
'FontAngle','italic', ...
'String','LOS Search',...
'Tag','TextLOSsearch',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'Enable','off',...
'Position',[.12 .40 .6 .02]);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
h0=uicontrol(props.button,... % Set Point
'Units','Normalized',...
'Tag','SetPoint',...
'String','Set Point',...
'Position',[.16 .36 .314 .032],...
'Enable','off',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'ToolTip','Set a Point on LOS.',...
'CallBack','crp2 LOSset');
h0=uicontrol(props.button,... % Clear Point
'Units','Normalized',...
'Tag','ClearPoint',...
'String','Clear P',...
'Position',[.52 .36 .314 .032],...
'Enable','off',...
'ToolTip','Clear a Point on LOS.',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'CallBack','crp2 LOSclear');
h0=uicontrol(props.button,... % Clear All Point
'Units','Normalized',...
'Tag','ClearAllPoint',...
'String','Clear All',...
'Position',[.52 .32 .314 .032],...
'Enable','off',...
'ToolTip','Clear All Points on LOS.',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'CallBack','crp2 LOSallclear');
h0=uicontrol(props.text,... % Text LOSwidthX
'Units','Normalized',...
'Tag','LOSwidthXtext',...
'String','dx:',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'Position',[.16 .274 .35 .02],...
'Enable','off');
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
h0=uicontrol(props.edit,... % Input LOSwidthX
'Units','Normalized',...
'Tag','LOSwidthX',...
'Position',[.315 .278 .15 .026],...
'String','1',...
'Enable','off',...
'ToolTip','Insert the LOS width in X-direction.' );
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
h0=uicontrol(props.text,... % Text LOSwidthY
'Units','Normalized',...
'Tag','LOSwidthYtext',...
'String','dy:',...
'Position',[.52 .274 .35 .02],...
'Enable','off',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor);
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h1(3) h1(4)])
h0=uicontrol(props.edit,... % Input LOSwidthY
'Units','Normalized',...
'Tag','LOSwidthY',...
'Position',[.679 .278 .15 .026],...
'String','1',...
'Enable','off',...
'ToolTip','Insert the LOS width in Y-direction.' );
h1=get(h0,'Extent'); h2=get(h0,'Position'); set(h0,'Position',[h2(1) h2(2) h2(3) h1(4)])
h0=uicontrol(props.button,... % Button ApplyLOSsearch
'Units','Normalized',...
'String','Apply',...
'Position',[.16 .23 .314 .032],...
'Tag','Apply2',...
'Callback','crp2 LOSsearch',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'Enable','off',...
'ToolTip','Searches the LOS.');
h0=uicontrol(props.button,... % Button Stores LOS
'Units','Normalized',...
'String','Store',...
'Position',[.52 .23 .314 .032],...
'Tag','Store2',...
'Callback','crp2 store2',...
'BackgroundColor',dark_factor*props.frame.BackgroundColor,...
'Enable','off',...
'ToolTip','Stores the LOS.');
if ~isunix
h0=uicontrol(props.frame, ... % Frame Embedding
'Units','Normalized',...
'Position',[.1 .15 .38 .045]);
end
h0=uicontrol(props.checkbox, ... % Checkbox Stretch Plot
'Units','Normalized',...
'Position',[.1 .15 .38 .045], ...
'String','Stretch', ...
'Tag','Stretch',...
'CallBack','crp2 stretch',...
'Value',1,...
'ToolTip','Streches the plotted CRP to a squared plot.' );
h0=uicontrol(props.button, ... % Button Store Matrix
'Units','Normalized',...
'Position',[.52 .15 .38 .045], ...
'String','Store Matrix', ...
'Style','pushbutton', ...
'Tag','Store',...
'CallBack','crp2 store',...
'Value',1,...
'ToolTip','Stores the CRP matrix into variable X in the workspace.' );
h0=uicontrol(props.button,... % Button Help
'Units','Normalized',...
'String','Help',...
'Position',[.1 .03 .38 .045],...
'Tag','Help',...
'Callback','helpwin crp2',...
'ToolTip','Opens the helpwindow.');
h0=uicontrol(props.button,... % Button Apply
'Units','Normalized',...
'String','Create Recurrence Plot',...
'Position',[.1 .09 .8 .045],...
'Tag','Apply',...
'Callback','crp2 compute',...
'ToolTip','Starts the computation - be patient.');
h0=uicontrol(props.button,... % Button Close
'Units','Normalized',...
'String','Close',...
'Position',[.52 .03 .38 .045],...
'Tag','Close',...
'Callback','crp2 close',...
'ToolTip','Closes CRP windows.');
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
set(h9, 'HandleVis','CallBack')
clear h0 h1 h8 h9
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% vectorexclude
errcode=4;
case 'exclude'
ds = get(findobj('Tag','DimEx','Parent',gcf),'UserData');
j=str2num(get(gco,'String'));
if ds(j,j)==1
set(gco,'ForegroundColor', [.5 0 0],...
'FontWeight','bold',...
'BackgroundColor', .8*props.button.BackgroundColor,...
'ToolTip','Include this vector.');
ds(j,j)= -1;
if -(trace(ds))==length(ds)
ds(j,j)= 1;
set(gco,'ForegroundColor', [0 0 0],'FontWeight','normal',...
'BackgroundColor', props.button.BackgroundColor,...
'ToolTip','Exclude this vector.');
else
h0=gcf; figure(hCRP)
h1=findobj('Tag','Data1'); set(h1(length(h1)-j+1),'Visible','off')
h2=findobj('Tag','Data2'); set(h2(length(h1)-j+1),'Visible','off')
figure(h0), clear h1 h0
end
else
set(gco,'ForegroundColor', [0 0 0],'FontWeight','normal',...
'BackgroundColor', props.button.BackgroundColor,...
'ToolTip','Exclude this vector.');
ds(j,j)= 1;
h0=gcf; figure(hCRP)
h1=findobj('Tag','Data1'); set(h1(length(h1)-j+1),'Visible','on')
h2=findobj('Tag','Data2'); set(h2(length(h1)-j+1),'Visible','on')
figure(h0), clear h1 h0
end
set(findobj('Tag','DimEx','Parent',gcf),'UserData', ds);
m1=length(find(sum(ds)+1));
set(findobj('Tag','Dim','Parent',gcf),'string', ['x ',num2str(m1)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% delay
case 'dimfit'
errcode=5;
m1=length(find(sum(ds)+1));
if m0~=1
set(findobj('Tag','Delay','Parent',gcf),'Enable', 'On');
else
set(findobj('Tag','Delay','Parent',gcf),'Enable', 'Off');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% unthresh
case 'unthresh'
errcode=6;
switch_unthresholded(hCRP)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% stretch
case 'stretch'
errcode=7;
stretch(hCRP,xscale,yscale,Nx,Ny)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% change colormap
case 'log'
errcode=82;
change_colormapscale(hCRP,cm)
case 'colormap'
errcode=81;
change_colormap(hCtrl,hCRP,cm)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% store
case 'store'
errcode=9;
X=get(findobj('Tag','CRPData','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'UserData');
if isempty(X)
warndlg('The CRP matrix is still empty. Please start the computation before storing.','Empty CRP')
waitforbuttonpress
else
assignin('base','X', double(X))
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% handlevisON
case 'handlevisON'
set(hCRP, 'HandleVis','on')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% close
case 'close'
errcode=101;
close_all
case 'smartclose'
errcode=102;
if ishandle(hCRP) & ishandle(hCtrl)
smart_close(hCRP,hCtrl)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% computation
case 'compute'
errcode=11;
txt_cross='Cross ';
if size(x)==size(y)
if x==y, txt_cross=''; end
end
if nogui==0
setptr([hCRP,hCtrl],'watch')
h=findobj('Tag','Apply','Parent',hCtrl);
obj.children=get(hCtrl,'Children');
obj.enable=get(obj.children,'Enable');
set(obj.children,'Enable','off')
set(h(1),'String','Stop',...
'ToolTip','Stops the computation.',...
'Enable','on',...
'Callback','set(gcbo,''String'',''Stopped'')')
end
h1=findobj('Parent',hCRP,'Tag','CRPPlot');
h2=findobj('Tag','Diagonal','Parent',h1);
if ~nogui
if isempty(h2)
h2=line('Parent',h1,'visible','off','Tag','Diagonal','color',[1 0 0],...
'LineWidth',1);
else
set(h2,'visible','off')
end
set(findobj('Tag','Store2','Parent',hCtrl),'Enable','Off')
set(findobj('Tag','Status','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'Visible','on')
set(findobj('Tag','CRPData','Parent',findobj('Parent',hCRP,'Tag','CRPPlot')),'Visible','off')
[plugin_exist, plugin_name, plugin_path] = is_crp_plugin;
if plugin_exist & ( mflag < 4 | mflag == 9 | mflag == 10 ) & length(x) == length(y) & ~ispc % if plugin exist and method is MAX, MIN, EUC ord DIS