function Y=segmentace(x,wind,overlen)


% delka vstupniho signalu
N=length(x);



if length(wind)>1
    
    winlen=length(wind);
else
    
    winlen=wind;
    
end



if overlen~=0
Sn= fix((N-winlen+overlen)/overlen);
indf= overlen*(0:(Sn-1))';
else
Sn  = fix((N)/winlen);
indf= winlen*(0:(Sn-1))';
end


% priprava vstupni matice
Y=zeros(winlen,Sn);
inds = (1:winlen);

Y(:) = x(indf(:,ones(1,winlen))'+inds(ones(Sn,1),:)');

% vynasobeni vahovacim oknem
if (length(wind) > 1)
     Y = Y.*repmat(wind,1,Sn);
 end