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

lowpass


Figure 111: Filter Specification for Highpass Filter

highpass


Figure 112: Filter Specification for Bandpass Filter

bandpass


Figure 113: Filter Specification for Bandstop Filter

bandstop


The digital filter passband frequency and stopband edge frequencies are omega Subscript p and omega Subscript s, 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 (omega Subscript p Baseline 1 and omega Subscript p Baseline 2) and two values of the stopband edge frequencies (omega Subscript s Baseline 1 and omega Subscript s Baseline 2). 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 delta 1 represents the magnitude of the passband ripple, which equals the maximum deviation from the unity magnitude. The symbol delta 2 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 upper R Subscript s and upper R Subscript s and are defined as

upper R Subscript p Baseline equals minus 20 normal l normal o normal g Subscript 10 Baseline left-parenthesis 1 minus delta 1 right-parenthesis (dB)

upper R Subscript s Baseline equals minus 20 normal l normal o normal g Subscript 10 Baseline left-parenthesis delta 2 right-parenthesis (dB)

where the absolute value of the passband ripple, upper R Subscript p, must be less than the absolute value of the stopband attenuation, upper R Subscript s; that is, StartAbsoluteValue upper R Subscript p Baseline EndAbsoluteValue less-than StartAbsoluteValue upper R Subscript s Baseline EndAbsoluteValue.

The values of the passband and stopband edge frequencies are normalized values between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (pi rad/sample). When the passband and stopband edge frequencies are specified, the following expressions must be satisfied:

Lowpass filter: omega Subscript p Baseline less-than omega Subscript s

Highpass filter: omega Subscript s Baseline less-than omega Subscript p

Bandpass filter: omega Subscript s Baseline 1 Baseline less-than omega Subscript p Baseline 1 Baseline less-than omega Subscript p Baseline 2 Baseline less-than omega Subscript s Baseline 2

Bandstop filter: omega Subscript p Baseline 1 Baseline less-than omega Subscript s Baseline 1 Baseline less-than omega Subscript s Baseline 2 Baseline less-than omega Subscript p Baseline 2

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 StartRoot 1 slash 2 EndRoot almost-equals 0.707 of the unity magnitude, which is approximately minus 20 normal l normal o normal g Subscript 10 Baseline left-parenthesis 0.707 right-parenthesis = 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 omega Subscript p. For a lowpass or highpass filter, omega Subscript p is a scalar value. For a bandpass or bandstop filter, omega Subscript p is a 1 times 2 or 2 times 1 vector. The values of the passband edge frequencies are between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (pi rad/sample).

Ws

specifies the stopband edge frequencies, which are denoted by the symbol omega Subscript s. For a lowpass or highpass filter, omega Subscript s is a scalar value. For a bandpass or bandstop filter, omega Subscript s is a 1 times 2 or 2 times 1 vector. The values of the stopband edge frequencies are between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (pi rad/sample).

Rp

is a scalar value that specifies the passband ripple, upper R Subscript p, in dB.

Rs

is a scalar value that specifies the stopband attenuation, upper R Subscript s, in dB. The absolute value of the passband ripple, upper R Subscript p, must be less than the absolute value of the stopband attenuation, upper R Subscript s; that is, StartAbsoluteValue upper R Subscript p Baseline EndAbsoluteValue less-than StartAbsoluteValue upper R Subscript s Baseline EndAbsoluteValue.

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, omega Subscript c, which the DFDESIGN subroutine can use to design the filter’s transfer function. For a lowpass or highpass filter, omega Subscript c is a scalar value. For a bandpass or bandstop filter, omega Subscript c is a 2 times 1 vector. The values of the cutoff frequencies are between 0 and 1, where 1 corresponds to the normalized Nyquist frequency (pi 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


Last updated: May 07, 2026