Documentation |
Measure filter magnitude response
measure(hd)
measure(hm)
measure(hs)
measure(hs)
measure(hd) returns measured values for specific points in the magnitude response curve for filter object hd. When you use a design object d to create a filter (by using fdesign.type to create d), you specify one or more values that define your desired filter response. measure(hd) tests the filter to determine the actual values in the magnitude response of the filter, such as the stopband attenuation or the passband ripple. Comparing the results returned by measure to the specifications you provided in the design object helps you assess whether the filter meets your design criteria.
Note To use measure, hd, hm, or hs must result from using a filter design method with a filter specifications object. measure works with multirate filters and discrete-time filters. The function does not support adaptive filters because you cannot use fdesign.type to construct adaptive filter specifications objects. |
measure(hd) returns measurements for the discrete-time filter hd. The function determines the relevant specifications based on the response type of the design object you use to create the filter. For example, for single-rate lowpass filters made from design objects, measure(hd) returns the following filter specifications.
Lowpass Filter Specification | Description |
---|---|
Sampling Frequency | Filter sampling frequency. |
Passband Edge | Location of the edge of the passband as it enters transition. |
3-dB Point | Location of the –3 dB point on the response curve. |
6-dB Point | Location of the –6 dB point on the response curve. |
Stopband Edge | Location of the edge of the transition band as it enters the stopband. |
Passband Ripple | Ripple in the passband. |
Stopband Atten | Attenuation in the stopband. |
Transition Width | Width of the transition between the passband and stopband, in normalized frequency or absolute frequency. Measured between Fpass and Fstop. |
In contrast, when you use a bandstop design object, measure(hd) returns these specifications for the resulting bandstop filter.
Bandstop Filter Specification | Description |
---|---|
Sampling Frequency | Filter sampling frequency. |
First Passband Edge | Location of the edge of the first passband. |
First 3-dB Point | Location of the edge of the –3 dB point in the first transition band. |
First 6-dB Point | Location of the edge of the –6 dB point in the first transition band. |
First Stopband Edge | Location of the start of the stopband. |
Second Stopband Edge | Location of the end of the stopband. |
Second 6-dB Point | Location of the edge of the –6 dB point in the second transition band. |
Second 3-dB Point | Location of the edge of the –3 dB point in the second transition band. |
Second Passband Edge | Location of the start of the second passband. |
First Passband Ripple | Ripple in the first passband. |
Stopband Atten | Attenuation in the stopband. |
Second Passband Edge | Ripple in the second passband. |
First Transition Width | Width of the first transition region. Measured between the –3 and –6 dB points. |
Second Transition Width | Width of the second transition region. Measured between the –6 and –3 dB points. |
measure(hm) returns measurements for the multirate filter hm. The set of filter specifications that measure returns for multirate filters might be different from those for discrete-time filters.
The set of response measurements that measure returns depends on the response you use to design the filter. For example, when hm is an FIR lowpass interpolator (whose response is lowpass), measure(hm) returns the following set of measurements.
Interpolator Filter Specification | Description |
---|---|
First Passband Edge | Location of the edge of the passband as it enters transition. |
3-dB Point | Location of the –3 dB point on the response curve. |
6-dB Point | Location of the –6 dB point on the response curve. |
Stopband Edge | Location of the edge of the transition band as it enters the stopband. |
Passband Ripple | Ripple in the passband. |
Stopband Atten | Attenuation in the stopband. |
Transition Width | Width of the transition between the passband and stopband, in normalized frequency or absolute frequency. Measured between Fpass and Fstop. |
For reference, the specification object d created the interpolator specifications shown in the preceding table:
d=fdesign.interpolator(6,'lowpass') d = MultirateType: 'Interpolator' InterpolationFactor: 6 Response: 'Lowpass' Specification: 'Fp,Fst,Ap,Ast' Description: {4x1 cell} NormalizedFrequency: true Fpass: 0.133333333333333 Fstop: 0.166666666666667 Apass: 1 Astop: 60
measure(hs) returns measurements for the filter System object™ hs. You must construct hs using design with the optional name-value pair argument 'SystemObject',true.
measure(hs) returns measurements for the filter System object hs with additional options specified by one or more Name,Value pair arguments.
For the first example, create a lowpass filter and check whether the actual filter meets the specifications. For this case, use normalized frequency for Fs, the default setting.
d2=fdesign.lowpass('Fp,Fst,Ap,Ast',0.45,0.55,0.1,80) d2 = Response: 'Lowpass' Specification: 'Fp,Fst,Ap,Ast' Description: {4x1 cell} NormalizedFrequency: true Fpass: 0.45 Fstop: 0.55 Apass: 0.1 Astop: 80 designmethods(d2) Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple ifir kaiserwin multistage hd2=design(d2) % Use the default equiripple design method. hd2 = FilterStructure: 'Direct-Form FIR' Arithmetic: 'double' Numerator: [1x68 double] PersistentMemory: false measure(hd2) ans = Sampling Frequency : N/A (normalized frequency) Passband Edge : 0.45 3-dB Point : 0.47794 6-dB Point : 0.48909 Stopband Edge : 0.55 Passband Ripple : 0.09615 dB Stopband Atten. : 80.2907 dB Transition Width : 0.1
Stopband Edge, Passband Edge, Passband Ripple, and Stopband Atten all meet the specifications.
Now, using Fs in linear frequency, create a bandpass filter, and measure the magnitude response characteristics.
d=fdesign.bandpass d = Response: 'Bandpass' Specification: 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2' Description: {7x1 cell} NormalizedFrequency: true Fstop1: 0.35 Fpass1: 0.45 Fpass2: 0.55 Fstop2: 0.65 Astop1: 60 Apass: 1 Astop2: 60 normalizefreq(d,false,1.5e3) % Convert to linear freq. hd=design(d,'cheby2'); measure(hd) ans = Sampling Frequency : 1.5 kHz First Stopband Edge : 0.2625 kHz First 6-dB Point : 0.31996 kHz First 3-dB Point : 0.32497 kHz First Passband Edge : 0.3375 kHz Second Passband Edge : 0.4125 kHz Second 3-dB Point : 0.42503 kHz Second 6-dB Point : 0.43004 kHz Second Stopband Edge : 0.4875 kHz First Stopband Atten. : 60 dB Passband Ripple : 0.17985 dB Second Stopband Atten. : 60 dB First Transition Width : 0.075 kHz Second Transition Width : 0.075 kHz
measure(hd) returns the actual response values, in the units you chose. In this example, all frequencies appear in kilohertz because the sampling frequency is in kilohertz.