fdesign.interpolator - Interpolator filter specification - MATLAB (original) (raw)
Interpolator filter specification
Note
You can no longer design an mfilt.firinterp
object using the fdesign.interpolator and the design functions. Use the design
function with theSystemObject
=true
flag to design an FIR interpolator System object™.
Syntax
D = fdesign.interpolator(L) D = fdesign.interpolator(L,RESPONSE) D = fdesign.interpolator(L,CICRESPONSE,D) D = fdesign.interpolator(L,RESPONSE,spec) D = fdesign.interpolator(...,spec,specvalue1,specvalue2,...) D = fdesign.interpolator(...,Fs) d = fdesign.interpolator(...,MAGUNITS)
Description
D = fdesign.interpolator(L)
constructs an interpolator filter specification object D
with the InterpolationFactor
property equal to the positive integer L
and the Response
property set to 'Nyquist'
. The default values for the transition width and stopband attenuation in the Nyquist design are 0.1π radians/sample and 80 dB. If L
is unspecified, L
defaults to 2.
D = fdesign.interpolator(L,RESPONSE)
constructs a interpolator specification object with the interpolation factor L
and the 'Response'
property set to one of the supported types.
D = fdesign.interpolator(L,CICRESPONSE,D)
constructs a CIC or CIC compensator interpolator specification object with the interpolation factor, L
, and 'Response'
property equal to 'CIC'
or 'CICCOMP'
. D
is the differential delay. The differential delay, D
, must precede any specification option.
D = fdesign.interpolator(L,RESPONSE,spec)
constructs object D
and sets its Specification
property to spec
. Entries in the spec
represent various filter response features, such as the filter order, that govern the filter design. Valid entries for spec
depend on the design type of the specifications object.
When you add the spec
input argument, you must also add the RESPONSE
input argument.
Because you are designing multirate filters, the specification options available are not the same as the specifications for designing single-rate filters with design methods such as fdesign.lowpass. The options are not case sensitive.
The interpolation factor L
is not in the specification options. The different filter responses support different specifications. The following table lists the supported response types and specification options.
Design Method | Valid Specification Options |
---|---|
'Arbitrary Magnitude' | See fdesign.arbmag for a description of the specification entries. 'N,F,A' (default option)'N,B,F,A' |
'Arbitrary Magnitude and Phase' | See fdesign.arbmagnphase for a description of the specification entries. 'N,F,H' (default option)'N,B,F,H' |
'Bandpass' | See fdesign.bandpass for a description of the specification entries. 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2' (default option)'N,Fc1,Fc2''N,Fst1,Fp1,Fp2,Fst2' |
'Bandstop' | See fdesign.bandstop for a description of the specification entries. 'N,Fc1,Fc2''N,Fp1,Fst1,Fst2,Fp2''Fp1,Fst1,Fst2,Fp2,Ap1,Ast,Ap2' (default option) |
'CIC' | 'Fp,Ast' — Only valid specification. Fp is the passband frequency and Ast is the stopband attenuation in decibels.To specify a CIC interpolator, include the differential delay after 'CIC' and before the filter specification: 'Fp,Ast'. For example: d = fdesign.interpolator(2,'cic',4,'Fp,Ast',0.4,40); |
'CIC Compensator' | See fdesign.ciccomp for a description of the specification entries. 'Fp,Fst,Ap,Ast' (default option)'N,Fc,Ap,Ast''N,Fp,Ap,Ast''N,Fp,Fst''N,Fst,Ap,Ast'To specify a CIC compensator interpolator, include the differential delay after 'CICCOMP' and before the filter specification. For example: d = fdesign.interpolator(2,'ciccomp',4); |
'Differentiator' | 'N' — filter order |
'Gaussian' | 'Nsym,BT — Nsym is the filter order in symbols and BT is the bandwidth-symbol time product.The specification must be preceded by an integer-valued SamplesPerSymbol. |
'Halfband' | See fdesign.halfband for a description of the specification entries. 'TW,Ast' (default option)'N,TW''N''N,Ast'If you use the quasi-linear IIR design method, iirlinphase, with a halfband specification, the interpolation factor must be 2. |
'Highpass' | See fdesign.highpass for a description of the specification entries. 'Fst,Fp,Ast,Ap' (default option)'N,F3db''N,Fc''N,Fc,Ast,Ap''N,Fp,Ast,Ap''N,Fst,Ast,Ap''N,Fst,Fp''N,Fst,Ast,Ap''N,Fst,Fp,Ast' |
'Hilbert' | See fdesign.hilbert for a description of the specification entries. 'N,TW' (default option)'TW,Ap' |
'Inverse-sinc Lowpass' | See fdesign.isinclp for a description of the specification entries. 'Fp,Fst,Ap,Ast' (default option) 'N,Fc,Ap,Ast''N,Fp,Fst''N,Fst,Ap,Ast' |
'Inverse-sinc Highpass' | See fdesign.isinchp for a description of the specification entries. 'Fst,Fp,Ast,Ap' (default option) 'N,Fc,Ast,Ap''N,Fst,Fp''N,Fst,Ast,Ap' |
'Lowpass' | See fdesign.lowpass for a description of the specification entries. 'Fp,Fst,Ap,Ast' (default option)'N,F3dB''N,Fc''N,Fc,Ap,Ast''N,Fp,Ap,Ast''N,Fp,Fst''N,Fp,Fst,Ap''N,Fp,Fst,Ast' 'N,Fst,Ap,Ast' |
'Nyquist' | See fdesign.nyquist for a description of the specification entries. For all Nyquist specifications, you must specify the _L_th band. This typically corresponds to the interpolation factor so that the nonzero samples of the upsampler output are preserved. 'TW,Ast' (default option)'N''N,Ast''N,Ast' |
D = fdesign.interpolator(...,spec,specvalue1,specvalue2,...)
constructs an object D
and sets its specifications at construction time.
D = fdesign.interpolator(...,Fs)
adds the argument Fs
, specified in Hz, to define the sampling frequency to use. In this case, all frequencies in the specifications are in Hz as well.
d = fdesign.interpolator(...,MAGUNITS)
specifies the units for any magnitude specification you provide in the input arguments. MAGUNITS
can be one of
'linear'
— specify the magnitude in linear units.'dB'
— specify the magnitude in dB (decibels).'squared'
— specify the magnitude in power units.
When you omit the MAGUNITS
argument, fdesign
assumes that all magnitudes are in decibels. Note that fdesign
stores all magnitude specifications in decibels (converting to decibels when necessary) regardless of how you specify the magnitudes.
Examples
These examples show how to construct interpolating filter specification objects.
First, create a default specifications object without using input arguments except for the interpolation factor l.
l = 2; d = fdesign.interpolator(l); %#ok
Now create an object by passing a specification option 'fst1,fp1,fp2,fst2,ast1,ap,ast2' and a design - the resulting object uses default values for all of the filter specifications. You must provide the design input argument when you include a specification.
d = fdesign.interpolator(8,'bandpass','fst1,fp1,fp2,fst2,ast1,ap,ast2'); %#ok
Create another interpolating filter object, passing the specification values to the object rather than accepting the default values for, in this case, fp,fst,ap,ast.
d = fdesign.interpolator(3,'lowpass',.45,0.55,.1,60); %#ok
Now pass the filter specifications that correspond to the specifications - n,fc,ap,ast.
d = fdesign.interpolator(3,'ciccomp',1,2,'n,fc,ap,ast',... 20,0.45,.05,50);
With the specifications object in your workspace, design an interpolator using the equiripple design method.
hm = design(d,'equiripple',SystemObject=true); %#ok
Pass a new specification type for the filter, specifying the filter order.
d = fdesign.interpolator(5,'CIC',1,'fp,ast',0.05,55);
With the specifications object in your workspace, design an interpolator using the multisection design method.
hm = design(d,'multisection',SystemObject=true); %#ok
In this example, you specify a sampling frequency as the right most input argument. Here, it is set to 1000 Hz.
d = fdesign.interpolator(8,'bandpass','fst1,fp1,fp2,fst2,ast1,ap,ast2',... 0.25,0.35,.55,.65,50,.05,1e3); %#ok
In this, the last example, use the linear option for the filter specification object and specify the stopband ripple attenuation in linear form.
d = fdesign.interpolator(4,'lowpass','n,fst,ap,ast',15,0.55,.05,0.001,... 'linear'); %#ok
Now design a CIC interpolator for a signal sampled at 19200 Hz. Specify the differential delay of 2 and set the attenuation of information beyond 50 Hz to be at least 80 dB.
% The filter object sampling frequency is (l x fs) where fs is the sampling frequency of the input signal.
dd = 2; % Differential delay. fp = 50; % Passband of interest. ast = 80; % Minimum attenuation of alias components in passband. fs = 600; % Sampling frequency for input signal. l = 32; % Interpolation factor. d = fdesign.interpolator(l,'cic',dd,'fp,ast',fp,ast,l*fs); hm = design(d,SystemObject=true); %Use the default design method.
This next example results in a minimum-order CIC compensator that interpolates by 4 and compensates for the droop in the passband for the CIC filter hm from the previous example.
nsecs = hm.NumSections; d = fdesign.interpolator(4,'ciccomp',dd,nsecs,... 50,100,0.1,80,fs); hmc = design(d,'equiripple',SystemObject=true);
hmc is designed to compensate for hm. To see the effect of the compensating CIC filter, use filterAnalyzer
to analyze both filters individually and include the compound filter response by cascading hm
and hmc
.
hfvt = filterAnalyzer(hmc,hm,cascade(hmc,hm),SampleRates=[fs,lfs,lfs],ReferenceFilter=false); showFilters(hfvt,false,FilterNames=["Filter_3_Stage1","Filter_3_Stage2"]); setLegendStrings(hfvt,["CIC Compensator","CIC Interpolator","Overall Response"]);
For the third example, use fdesign.interpolator to design a minimum-order Nyquist interpolator that uses a Kaiser window. For comparison, design a multistage interpolator as well and compare the responses.
l = 15; % Set the interpolation factor and the Nyquist band. tw = 0.05; % Specify the normalized transition width. ast = 40; % Set the minimum stopband attenuation in dB. Fs = 2; % For normalized frequency units d = fdesign.interpolator(l,'nyquist',l,tw,ast); hmK = design(d,'kaiserwin',SystemObject=true); hmMulti = designMultistageInterpolator(l,Fs/l,tw,ast); % Design the multistage interpolator. hfvt = filterAnalyzer(hmK,hmMulti); showFilters(hfvt,false,FilterNames=["hmMulti_Stage1","hmMulti_Stage2"]) setLegendStrings(hfvt,["Kaiser Window","Multistage"])
Design a lowpass interpolator for an interpolation factor of 8. Compare the single-stage equiripple design to a multistage design with the same interpolation factor.
l = 8; % Interpolation factor. d = fdesign.interpolator(l,'lowpass'); hmequi = design(d,'equiripple',SystemObject=true); % Use halfband filters whenever possible. hmmultiInterp = designMultistageInterpolator(l)
hmmultiInterp = dsp.FilterCascade with properties:
Stage1: [1×1 dsp.FIRInterpolator]
Stage2: [1×1 dsp.FIRInterpolator]
Stage3: [1×1 dsp.FIRInterpolator]
CloneStages: false
hfvtlp = filterAnalyzer(hmequi,hmmultiInterp); showFilters(hfvt,false,FilterNames=["hmmultiInterp_Stage1","hmmultiInterp_Stage2","hmmultiInterp_Stage3"]) setLegendStrings(hfvtlp,["Single-Stage Equiripple","Multistage"])
Version History
Introduced in R2011a
You can no longer design an mfilt.firinterp
object using the fdesign.interpolator and the design functions.
To design an FIR interpolator using the fdesign.interpolator
filter specification object, use the design
function with theSystemObject
=true
flag. Setting this flag totrue
ensures that the output object is a filter System object instead of an mfilt.firinterp
object.
fdesignObj = fdesign.interpolator; FIRInterpObj = design(fdesignObj,SystemObject=true)
FIRInterpObj =
dsp.FIRInterpolator with properties:
InterpolationFactor: 2
NumeratorSource: 'Property'
Numerator: [-3.0325e-05 0 8.3413e-05 0 … ]
Show all properties
Support for multistage filter design using the fdesign.interpolator
object will be removed in a future release. Use the designMultistageInterpolator function instead.
Update Code
This table shows how to update your code.
Discouraged Usage | Recommended Replacement |
---|---|
Using the design function and passing the'multistage' flag as an input.L = 12; % Interpolation factor TW = 2205; % Transition width Astop = 80; % Stopband attenuation Fs = 44100; % Output sample rate filtSpec = fdesign.interpolator(L,'nyquist',L,TW,Astop,Fs); filtObj = design(filtSpec,'multistage',SystemObject=true) | When you set the cost method to 'design', the function designs an optimal number of stages so that the overall cost of implementation is low. filtObj = designMultistageInterpolator(L,Fs,TW,Astop,... CostMethod='design') |
Using the multistage function directly.filtObj = multistage(filtSpec,SystemObject=true) |