function [res_signals, pq]=resample_TH(signals,p,q)

t=gcd(p,q);  

    p=p/t; 
    q=q/t; 
    t=1:q:(p*size(signals,2)); 
    res_signals=zeros(size(signals,1), size(t,2)); 
     T=q; 
    [h]=raised_cosine_ImpResp(T,0.5); 
    
for n=1:size(signals,1)
    % up-sample
    x=ones(p,1)*signals(n,:); 
    x=x(:)';
    % lowpaass-filter
   
    x=conv(x,h/T,'same'); 
    % downsample
    res_signals(n,:)=x(1,1:q:end); 
    
end
pq=p/q; 
end

function [h]=raised_cosine_ImpResp(T,beta)
t=-4*T:4*T;
h=sinc(t/T).*cos(pi*beta.*t/T)./(1-4*beta^2*t.^2/T^2); 
h(1,isinf(h))=0; 
end