Prev Next fn2dbs

Converting From A Normalized To Digital Bandstop Filter
Syntax fn2dbs(wc, dt, b_in, a_in, bz, az)
Include: include spt\fn2dbs.oms
See Also fn2dlp , fn2dhp , fn2dbp , 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 bandstop filter.
    dt: Real or Double scalar, sampling interval, in [seconds]
  b_in: Real or Double column vector, input numerator polynomial of the normalized continuous bandstop 
        prototype filter.
  a_in: Real or Double column vector, input denominator polynomial of the normalized continuous bandstop 
        prototype filter.
    bz: Real or Double column vector, output numerator   polynomial for the digital bandstop filter.
    az: Real or Double column vector, output denominator polynomial for the digital bandstop filter.

Description

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.

Example

# Design CHEB2 lowpass prototype filter, fc = 1 [radian/sec]
Norder  = 5;                  # Filter Order
Ap      = 1d0;                # Passband Ripple [dB]
As      = 50d0;               # Stopband Ripple [dB]
b       = novalue;            # Declare numerator   polynomial
a       = novalue;            # Declare denominator polynomial
fncheb2(Norder,Ap,As,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
fn2dbs(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       = 501; # Plotting information         
n       = seq(N)'-1d0;
f       = logspace(log10(fmin),log10(fs/2),N)';
H       = gainz(bz,az,f,fs);
HdB     = db20(H);