function Sinterp = Gibbs(S,T,seuil,optfenetre);   
    % Sinterp = Gibbs(S,T,seuil,optfenetre);  
    %
    %Etant donne un signal a temps discret S 
    %sur la grille -T:T/N:T et un seuil entre 0 et 1,  
    %cette routine retourne le signal obtenu en coupant 
    %symetriquement les hautes frequences a hauteur 
    %de seuil*N/(4*T); on prendra optfenetre = 're' 
    %(fenetre rectangulaire), optfenetre = 'tr' (fenetre 
    %triangulaire) ou optfenetre = 'hm' (fenetre de hamming). 
    %Cette routine met en evidence le phenomene de Gibbs.     
sizeS   = size(S);N = length(S)-1; S = reshape(S,[1,N+1]); 
NN      = fix(N/2); MM = round(NN*seuil); 
if optfenetre == 're'
    fenetre = ones(1,2*MM+1); 
elseif optfenetre == 'tr'    
    fenetre = triang(2*MM +1)'; 
elseif optfenetre == 'hm' 
    fenetre = hamming(2*MM+1)'; 
end
H       = [zeros(1,NN-MM),fenetre,zeros(1,NN-MM)]; 
[Shat,Omega] = SPECTREgen(S,T); Shat_tronc = Shat.*H; 
Sinterp = ISPECTREgen(Shat_tronc,Omega); 
Sinterp = reshape(Sinterp,sizeS);  
end

