Language Reference
DFORDER Call
CALL DFORDER (n, Wc, filterName, filterType, Wp, Ws, Rp, Rs) ;
This subroutine is supported by the IML procedure and the iml action.
The DFORDER subroutine computes the minimum required order for a digital filter that satisfies a requirement that you specify. Digital filters are designed by specifying the frequency response of the filters in the frequency domain. The specification includes a digital filter’s passband and stopband edge frequencies, passband ripple, and stopband attenuation. Figure 110 through Figure 113 illustrate the filter specification for each type of digital filter (Oppenheim and Schafer 2010; Parks and Burrus 1987).
Figure 110: Filter Specification for Lowpass Filter
Figure 111: Filter Specification for Highpass Filter
Figure 112: Filter Specification for Bandpass Filter
Figure 113: Filter Specification for Bandstop Filter
The digital filter passband frequency and stopband edge frequencies are and
, respectively. For lowpass and highpass filters, you need to specify only one value of each edge frequency. However, for bandpass and bandstop filters, you need to specify two values of the passband edge frequencies (
and
) and two values of the stopband edge frequencies (
and
). The frequency range from the passband edge frequency to the stopband edge frequency is the transition band. The transition band has a frequency response that is unspecified (Oppenheim and Schafer 2010; Parks and Burrus 1987; Roy 2005; Constantinides 1970).
The digital filter passband and stopband can contain oscillations known as ripples. The symbol represents the magnitude of the passband ripple, which equals the maximum deviation from the unity magnitude. The symbol
represents the magnitude response of the stopband attenuation, which equals the maximum deviation from zero. The passband ripple (Rp) and stopband attenuation (Rs) are usually measured in decibels (dB). They are represented by the symbols
and
and are defined as
where the absolute value of the passband ripple, , must be less than the absolute value of the stopband attenuation,
; that is,
.
The values of the passband and stopband edge frequencies are normalized values between 0 and 1, where 1 corresponds to the normalized Nyquist frequency ( rad/sample). When the passband and stopband edge frequencies are specified, the following expressions must be satisfied:
In addition to the minimum required order for a digital filter that satisfies the input requirement, the DFORDER subroutine also outputs the digital filter’s cutoff frequencies, which the DFDESIGN subroutine can use to design the filter’s transfer function. A digital filter’s cutoff frequency is defined as the frequency at which the power of the frequency response reaches half the unity power, or equivalently of the unity magnitude, which is approximately
= 3 in dB. Because half power is about 3dB away from unity power, this frequency is often called the 3dB cutoff frequency.
The input arguments to the DFORDER subroutine are as follows:
- filterName
is a string that specifies the name of the desired digital filter. Currently only the Butterworth filter is supported. The input string can be "BUTTER" or "BUTTERWORTH" and is not case-sensitive.
- filterType
is a string that specifies the type of the desired digital filter. It is one of the following four values: "LOWPASS", "HIGHPASS", "BANDPASS", or "BANDSTOP". The input string is not case-sensitive.
- Wp
specifies the passband edge frequencies, which are denoted by the symbol
. For a lowpass or highpass filter,
is a scalar value. For a bandpass or bandstop filter,
is a
or
vector. The values of the passband edge frequencies are between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (
rad/sample).
- Ws
specifies the stopband edge frequencies, which are denoted by the symbol
. For a lowpass or highpass filter,
is a scalar value. For a bandpass or bandstop filter,
is a
or
vector. The values of the stopband edge frequencies are between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (
rad/sample).
- Rp
is a scalar value that specifies the passband ripple,
, in dB.
- Rs
is a scalar value that specifies the stopband attenuation,
, in dB. The absolute value of the passband ripple,
, must be less than the absolute value of the stopband attenuation,
; that is,
.
The DFORDER subroutine returns the following values:
- n
is the minimum required order for a digital filter that satisfies the input requirement.
- Wc
is the digital filter’s cutoff frequencies,
, which the DFDESIGN subroutine can use to design the filter’s transfer function. For a lowpass or highpass filter,
is a scalar value. For a bandpass or bandstop filter,
is a
vector. The values of the cutoff frequencies are between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (
rad/sample).
The following statements use the DFORDER call to compute the minimum required order and cutoff frequencies for a Butterworth lowpass filter:
filter_name = "butter";
filter_type = "lowpass";
Wp = 0.125;
Ws = 0.25;
Rp = 3;
Rs = 50;
call dforder(n, Wc, filter_name, filter_type, Wp, Ws, Rp, Rs);
print n, Wc;
Figure 114: Output from the DFORDER Call for a Lowpass Filter
| n |
|---|
| 8 |
| Wc |
|---|
| 0.1267115 |
The following statements use the DFORDER call to compute the minimum required order and cutoff frequencies for a Butterworth highpass filter:
filter_name = "butter";
filter_type = "highpass";
Wp = 0.5;
Ws = 0.25;
Rp = 3;
Rs = 40;
call dforder(n, Wc, filter_name, filter_type, Wp, Ws, Rp, Rs);
print n, Wc;
Figure 115: Output from the DFORDER Call for a Highpass Filter
| n |
|---|
| 6 |
| Wc |
|---|
| 0.4638373 |
The following statements use the DFORDER call to compute the minimum required order and cutoff frequencies for a Butterworth bandpass filter:
filter_name = "butter";
filter_type = "bandpass";
Wp = 0.25 || 0.5;
Ws = 0.125|| 0.625;
Rp = 3;
Rs = 40;
call dforder(n, Wc, filter_name, filter_type, Wp, Ws, Rp, Rs);
print n, Wc;
Figure 116: Output from the DFORDER Call for a Bandpass Filter
| n |
|---|
| 7 |
| Wc |
|---|
| 0.2428073 |
| 0.5102878 |
The following statements use the DFORDER call to compute the minimum required order and cutoff frequencies for a Butterworth bandstop filter:
filter_name = "butter";
filter_type = "bandstop";
Wp = 0.125 || 0.625;
Ws = 0.25 || 0.5;
Rp = 3;
Rs = 40;
call dforder(n, Wc, filter_name, filter_type, Wp, Ws, Rp, Rs);
print n, Wc;
Figure 117: Output from the DFORDER Call for a Bandstop Filter
| n |
|---|
| 7 |
| Wc |
|---|
| 0.1804219 |
| 0.6098648 |