


%%%% design a Chebyshev-Type-II bandpass ( f1 to f2 Hz) filter 
function Hd = bandp_filter(f1, f2, fs)
    
    Fstop1 = f1-0.3;  % First Stopband Frequency
    Fpass1 = f1;    % First Passband Frequency
    Fpass2 = f2;    % Second Passband Frequency
    Fstop2 = f2+0.3;  % Second Stopband Frequency
    Astop1 = 60;   % First Stopband Attenuation (dB)
    Apass  = 0.5;    % Passband Ripple (dB)
    Astop2 = 80;   % Second Stopband Attenuation (dB)

    Fstop = [Fstop1 Fstop2];
    Astop = max(Astop1,Astop2);
    N     = cheb2ord([Fpass1 Fpass2]/(fs/2), Fstop/(fs/2), Apass, Astop);
    [z,p,k] = cheby2(N,Astop,Fstop/(fs/2));
    [sos_var,g] = zp2sos(z, p, k);
    Hd          = dfilt.df2sos(sos_var, g);

end