%function [] = wlegandr(data,point)
%WLEGANDR Summary of this function goes here
%  Detailed explanation goes here
win_D=0;
for win=2500:400:4100;
% win=100; 
 step=1; sn=2; %point=9700;
%data=data(1307:2974,:);

[rw,cw]=size(data);
wdata=zeros(win,(rw-win));
for ii=1:step:rw-win;
    wdata(1:win,ii)=data(ii:ii+win-1,sn);
end
 jj=1; [rw,cw]=size(wdata);
for ii=1:cw
   if wdata(1,ii)~=0 
      wdata1(1:rw,jj)=wdata(1:rw,ii);
        jj=jj+1;
    end
end
wdata=wdata1; %wdata2=wdata3;
clear ii jj rw cw wdata1
[rw,cw]=size(wdata);
xxx=zeros(1,cw); xxy=zeros(50,cw); xxz=zeros(50,cw);
for ii=1:cw
    clear xy xz f_alpha1 alpha1
    x=wdata(:,ii);
N = length(x) ;
Nscale = max(2,round(log2(N/16))); 
[wt,scale] = contwtmir(x,2^(-Nscale),2^(-1),2*Nscale,8*i) ;
Q = linspace(-4,4,50) ;
[alpha,f_alpha] = contwtspec(wt,scale,Q,1,0);
xy=length(alpha); alpha1(1:(50-xy))=alpha(xy); alpha=[alpha alpha1]; 
xz=length(f_alpha); f_alpha1(1:(50-xz))=f_alpha(xz); f_alpha=[f_alpha f_alpha1];
xxy(1:length(alpha),ii)=alpha(:);
xxz(1:length(f_alpha),ii)=f_alpha(:);
xxx(1,ii)=ii;
end
xxx=repmat(xxx,50,1);


clear xy xz f_alpha1 alpha1 N Nscale Q f_alpha alpha scale
clear wdata x xy xz wt ii


[rw,cw]=size(xxz);
for ii=1:rw
    xxz_max(ii,win-win+1)=max(xxz(:,ii));
end

win_D=win_D+1;
D(win_D)=mean(xxz_max);
save D.dat D -ascii


[rw,cw]=size(data);
wdata=zeros(win,(rw-win));
wdata2=zeros(win,(rw-win));
for ii=1:step:rw-win;
    wdata(1:win,ii)=data(ii:ii+win-1,sn);
    wdata2(1:win,ii)=data(ii:ii+win-1,1);
end
 jj=1; [rw,cw]=size(wdata);
for ii=1:cw
   if wdata(1,ii)~=0
      wdata1(1:rw,jj)=wdata(1:rw,ii);
      wdata3(1:rw,jj)=wdata2(1:rw,ii);
      jj=jj+1;
    end
end

wdata=wdata1; wdata2=wdata3;
clear ii jj rw cw step wdata1 

wdata2=max(wdata2); wdata31=wdata2; [rw,cw]=size(wdata2);

end