Fonction Scilab
fr


filter_tap

Contenu du fichier


//filter_tap macro qui retourne les coefficients d'une
//réponse impulsionnelle pour filtrage RIF
//05-01-2005 Alan Layec -IRCOM Lab-
//
//typ = 1 : Square Root Raised Cosine (param : alpha=roll-off)
//    = 2 : Raised Cosine (param : alpha=roll-off)
//    = 3 : Gauss (param : beta=BT)
//nb_coef : desired lenght of impulse response
//fe      : sampling frequency
//param   : parameters of response (see typ description)
//gain    : output gain
//
//ex :
//nb_coef=64
//Ne=12
//r=0.35
//gain=1
//[pulse]=filter_tap(1,64,Ne,r,gain)
function [pulse,t_Ts]=filter_tap(typ,nb_coef,fe,param,gain)

  //## Check input type
  if typ<>1&typ<>2&typ<>3 then
    message('Only 1,2 or 3 must be choosen for type of filtering');
    pulse = []
    t_Ts  = []
    return
  end

  //## Time vector
  //t_Ts=1/fe*(-nb_coef/2:nb_coef/2-1);
  t_Ts=1/fe*(-nb_coef/2:nb_coef/2-1)+0.5/fe;

  //## SRRC
  if typ==1 then

    r=param;
    for i=1:size(t_Ts,2)
      if t_Ts(i)==0 then
        pulse(i) = gain*4*r/%pi*(1-%pi/(4*r)*(r-1));
      elseif abs(t_Ts(i)*r)==1/4 then
        pulse(i) = gain*4*r/%pi*(sqrt(2)/8)*(%pi*(cos(%pi/(4*r))+sin(%pi/(4*r)))+2*(sin(%pi/(4*r))-cos(%pi/(4*r))));
      else
        pulse(i) = gain*4*r/%pi*(cos((1+r)*%pi*t_Ts(i)) + sin((1-r)*%pi*t_Ts(i))/(4*r*t_Ts(i)))/(1-(4*r*t_Ts(i))^2);
      end
    end
    pulse=pulse'

  //## RC
  elseif typ==2 then

    r=param;
    h1=cos(%pi*r*t_Ts)./(1-(4*r^2*t_Ts.^2)+(abs(r*t_Ts)==1/2))+(abs(r*t_Ts)==1/2)*%pi/4;
    h2=(sin(%pi*t_Ts))./(%pi*t_Ts+(t_Ts==0))+(t_Ts==0);

    pulse=gain*(h1.*h2);

  //## Gauss
  elseif typ==3 then

    b=param;
    pulse=1/fe*gain*b*sqrt((2*%pi)/log(2))*exp(-2/log(2)*(b*%pi*t_Ts)^2);

  end

endfunction