Prev Next fn2dbp

Converting From A Normalized To Digital Bandpass Filter [O-Matrix function]
Syntax fn2dbp(wc, dt, b_in, a_in, bz, az)
Include: O-Matrix function. No include equired.
See Also fn2dlp , fn2dhp , fn2dbs , fc2dig

    wc: Real or Double two-element Row Vector, [wc_lo,wc_hi], specifying desired lower and upper radian
        cutoff frequencies for the new digital bandpass filter.
    dt: Real or Double scalar, sampling interval, in [seconds]
  b_in: Real or Double column vector, input numerator polynomial of the normalized continuous bandpass 
        prototype filter.
  a_in: Real or Double column vector, input denominator polynomial of the normalized continuous bandpass 
        prototype filter.
    bz: Real or Double column vector, output numerator   polynomial for the digital bandpass filter.
    az: Real or Double column vector, output denominator polynomial for the digital bandpass filter.


This function converts an input continuous domain rational transfer function (H = b_in/a_in) to its corresponding z-domain digital transfer function. The function is intended to be used with normalized, s-domain, lowpass filter functions as can be obtained from functions such as: fnbut , fncheb1 , fncheb2 , fnbes .

The sampling interval for the new filter is "dt", making the system sampling rate fs = 1/dt. Generally, the new desired lower and upper cutoff frequencies are in [radians/sec], wc = 2*PI*fc, and should each be strictly less than half of the sampling rate.

The complex gain for this resulting filter can be evaluated with the gainz function.

The output z-domain polynomial "bz" and "az" must be declared before calling the function, though their types do not matter.


# Design CHEB1 lowpass prototype filter, fc = 1 [radian/sec]
Norder  = 5;                  # Filter Order
Ap      = 1d0;                # Passband Ripple [dB]
b       = novalue;            # Declare numerator   polynomial
a       = novalue;            # Declare denominator polynomial
fncheb1(Norder,Ap,b,a);       # Make analog prototype lowpass filter

# Convert filter to a digital filter
bz  = novalue;                # Declare output numerator   polynomial
az  = novalue;                # Declare output denominator polynomial
fs  = 100e3;                  # Sampling Frequency [Samples/sec] = [Hz]
dt  = 1d0/fs;                 # Sampling interval [Sec]
flo = 1d3;                    # New lower cutoff frequency
fhi = 5d3;                    # New upper cutoff frequency
wc  = 2d0*PI*[flo,fhi];       # Equivalent radian frequencies
fn2dbp(wc, dt, b, a, bz, az); # Convert the filter

# Evaluate this filter around its cutoff.
fmin    =  1d2; # Plotting Limits
fmax    =  fs;
ymax    =  10d0;
ymin    = -100d0;
ny = round((ymax-ymin)/10d0);

N       = 201; # Plotting information         
n       = seq(N)'-1d0;
f       = logspace(log10(fmin),log10(fs/2),N)';
H       = gainz(bz,az,f,fs);
HdB     = db20(H);