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)
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 |
---|---|
| Filter sampling frequency. |
| Location of the edge of the passband as it enters transition. |
| Location of the –3 dB point on the response curve. |
| Location of the –6 dB point on the response curve. |
| Location of the edge of the transition band as it enters the stopband. |
| Ripple in the passband. |
| Attenuation in the stopband. |
| Width of the transition between the passband and stopband,
in normalized frequency or absolute frequency. Measured between |
In contrast, when you use a bandstop design object, measure(hd)
returns
these specifications for the resulting bandstop filter.
Bandstop Filter Specification | Description |
---|---|
| Filter sampling frequency. |
| Location of the edge of the first passband. |
| Location of the edge of the –3 dB point in the first transition band. |
| Location of the edge of the –6 dB point in the first transition band. |
| Location of the start of the stopband. |
| Location of the end of the stopband. |
| Location of the edge of the –6 dB point in the second transition band. |
| Location of the edge of the –3 dB point in the second transition band. |
| Location of the start of the second passband. |
| Ripple in the first passband. |
| Attenuation in the stopband. |
| Ripple in the second passband. |
| Width of the first transition region. Measured between the –3 and –6 dB points. |
| 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 |
---|---|
| Location of the edge of the passband as it enters transition. |
| Location of the –3 dB point on the response curve. |
| Location of the –6 dB point on the response curve. |
| Location of the edge of the transition band as it enters the stopband. |
| Ripple in the passband. |
| Attenuation in the stopband. |
| Width of the transition between the passband and stopband,
in normalized frequency or absolute frequency. Measured between |
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(
returns
measurements for the filter System object™ hs
)hs
.
You must construct hs
using design
with
the optional name-value pair argument 'SystemObject',true
.
measure(
returns
measurements for the filter System object hs
)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.