function [y2, znelost, Y] = STE_final(y, Fs, delka_okna)

    [Y, pocet_oken, pocet_vzorku_okna, remainder] = SEG_A_DOPLN(y, Fs, delka_okna);
    
    
    for n = 1:pocet_oken
        max_hodnota_okna(n) = max(Y(:,n));  
        E(n)=(sum(Y(:,n).^2)/pocet_vzorku_okna)/max_hodnota_okna(n);       %energie okna  
    
        bily_sum(:,n) = (max(E)-min(E)).*rand(pocet_vzorku_okna,1) + min(E);
        E_bileho_sumu(n) = (sum(bily_sum.^2)/pocet_vzorku_okna)/max(bily_sum);
    end
    
    
    
    for n = 1:pocet_oken
        if E(n) >= E_bileho_sumu(n)
            znelost(n) = 1;
        else
            znelost(n) = 0;
        end
    end
    
    
    for n = 1:1:pocet_oken
    
        if znelost(n) == 0
            Y(:,n) = 0;            
        else
            Y(:,n) = Y(:,n);
        end
        
    end
        
        
     y2 = reshape(Y,1,[]);
     y2 = y2(1:end - (pocet_vzorku_okna-remainder));
     
end