function RES=waventropy_dynamic(Y,windowWidth,windowStep,actionType,wttype,wetype,plotOn)

if (nargin<7) plotOn=0; end
if (nargin<6) wetype=1; end
if (nargin<5) wttype=1; end
if (nargin<4) actionType=1; end
if (nargin<3) windowStep=1; end
if (nargin<2)
    return;
end

[m,n]=size(Y);
if (m<n)
    Y=Y'; [m,n]=size(Y);
end
Y=Y(:,1); [m,n]=size(Y);

startIndex=1;
endIndex=windowWidth;
RES=[];

if (wttype==1)
    title_add='DWT, ';
elseif (wttype==2)
    title_add='CWT, ';
elseif (wttype==3)
    title_add='DWT_c_s, ';
end

if (wetype==1)
    title_add=[title_add 'on scales'];
elseif (wetype==2)
    title_add=[title_add 'on points'];
end

waitBar=waitbar2(0,'Dynamic entropy calculating...','BarColor','b');
while (endIndex<=m)
    waitbar2(endIndex/m,waitBar);
    X=Y(startIndex:endIndex);
    [SWT,E,P]=waventropy(X,wttype,wetype);
    RES=[RES SWT];
    endIndex=endIndex+windowStep;
    if (actionType==1)
        startIndex=startIndex+windowStep;
    end
end
close(waitBar);

if (plotOn==1)
    [m1,n1]=size(RES);
    f=figure;
    subplot(2,1,1); plot(RES,'k');
    title(['Entropy dynamic: ' title_add]);
    subplot(2,1,2); plot(Y(windowWidth:m),'k');
    title('Source TS');
    kpfun(f);
end