fdesign.lowpass; error messages of one of examples

11 visualizaciones (últimos 30 días)
Jongsoo Kim
Jongsoo Kim el 3 de Jul. de 2024
Comentada: Aditya el 3 de Jul. de 2024
D = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2,0.25,1,60);
Hd = design(D,'equiripple','StopbandShape','linear','StopbandDecay',20);
Why does the above example, which is provided as one of exmaples of fdesign.lowpass, generate the following error messages?
'StopbandShape' is not a valid design option for EQUIRIPPLE.
Hd = feval(method, this, varargin{:},sysObjArgsDesign{:});
varargout{1} = superdesign(this, varargin{:});
Any suggestion to make it work.

Respuestas (3)

Aditya
Aditya el 3 de Jul. de 2024
Editada: Aditya el 3 de Jul. de 2024

Jongsoo Kim
Jongsoo Kim el 3 de Jul. de 2024
The above answer doesn't help to me. I already read the fdesign.lowpass function document.
What I wanted is to use the options, 'StopbandShape','linear','StopbandDecay',20, which should generate a decaying filter responsse in the stop band.
Thanks any your reply.
  1 comentario
Aditya
Aditya el 3 de Jul. de 2024
The issue you are encountering is likely due to the absence of the DSP System Toolbox in your MATLAB installation. The fdesign.lowpass function and some of its advanced design options, such as 'StopbandShape' and 'StopbandDecay', require the DSP System Toolbox to be installed. Without this toolbox, these options are not available, leading to the error messages you are seeing.
To verify whether the DSP System Toolbox is installed and whether you can access the 'StopbandShape' option, try the following commands:
>> D = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2,0.25,1,60);
>> help(D, 'equiripple')
If the DSP System Toolbox is installed, you should see the following information, which includes the 'StopbandShape' option:
>> help(D, 'equiripple')
DESIGN Design a Equiripple FIR filter.
HD = DESIGN(D, 'equiripple') designs a Equiripple filter specified by the
FDESIGN object D, and returns the DFILT/MFILT object HD.
HD = DESIGN(D, ..., 'SystemObject', true) implements the filter, HD,
using a System object instead of a DFILT/MFILT object.
HD = DESIGN(..., 'FilterStructure', STRUCTURE) returns a filter with the
structure STRUCTURE. STRUCTURE is 'dffir' by default and can be any of
the following:
'dffir'
'dffirt'
'dfsymfir'
'fftfir'
Some of the listed structures may not be supported by System object
filters. Type validstructures(D, 'equiripple', 'SystemObject', true) to
get a list of structures supported by System objects.
HD = DESIGN(..., 'DensityFactor', DENS) specifies the grid density DENS
used in the optimization. DENS is 16 by default.
HD = DESIGN(..., 'MinPhase', MPHASE) designs a minimum-phase filter
when MPHASE is TRUE. MPHASE is FALSE by default.
HD = DESIGN(..., 'MaxPhase', MPHASE) designs a maximum-phase filter
when MPHASE is TRUE. MPHASE is FALSE by default.
HD = DESIGN(..., 'MinOrder', 'any') designs a minimum-order filter.
The order of the filter can be even or odd. This is the default.
HD = DESIGN(..., 'MinOrder', 'even') designs a minimum-even-order filter.
HD = DESIGN(..., 'MinOrder', 'odd') designs a minimum-odd-order filter.
HD = DESIGN(..., 'StopbandShape', SHAPE) designs a filter whose stopband
has the shape defined by SHAPE. SHAPE can be 'flat', '1/f', or 'linear'.
SHAPE is 'flat' by default.
HD = DESIGN(..., 'StopbandDecay', DECAY) specifies the decay to use when
'StopbandShape' is not set to 'flat'. When the shape is '1/f' this
specifies the power that 1/f is raised. When shaped is 'linear' this
specifies the slope of the stopband in dB/rad/s.
HD = DESIGN(..., 'UniformGrid', UGRID) specifies the type of frequency
grid that is used to measure the error between the actual and the desired
frequency response of the filter. When UGRID is TRUE, approximation errors
are measured over a uniform frequency grid. When UGRID is FALSE, a non-uniform
frequency grid is used. In some cases, emphasizing the number of frequency
points in the proximity of transition regions of the filter response may
improve the design. If omitted, UGRID defaults to TRUE except when 'MinPhase'
'MaxPhase', 'MinOrder', or 'StopbandShape' options are set to non-default values.
% Example #1 - Design a lowpass Equiripple filter in a transposed structure.
h = fdesign.lowpass('Fp,Fst,Ap,Ast');
Hd = design(h, 'equiripple', 'FilterStructure', 'dffirt');

Iniciar sesión para comentar.


Star Strider
Star Strider el 3 de Jul. de 2024
@Jongsoo Kim — Your posted code works in R2024a, as demonsttrated here. You did not post the version you are using, and there could be version differences. The current online documentation is for R2024a only.
Run this in your Command Window:
help fdesign.lowpass
or to open the help browser entry for it:
doc fdesign.lowpass
again as I did here however in your Command Window, to see what tthe options are in your version.
D = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2,0.25,1,60);
Hd = design(D,'equiripple','StopbandShape','linear','StopbandDecay',20);
figure
freqz(Hd.Numerator,1, 2^16)
help fdesign.lowpass
LOWPASS Construct a lowpass filter designer. D = FDESIGN.LOWPASS(SPECSTRING,VALUE1,VALUE2,...) constructs a lowpass filter designer D. Note that D is not the design itself, it only contains the design specifications. In order to design the filter, one needs to invoke the DESIGN method on D. For example (more examples below): D = fdesign.lowpass('Fp,Fst,Ap,Ast',0.4,0.5,1,80); H = design(D,'equiripple'); % H is a DFILT SPECSTRING is a string that determines what design specifications will be used. There are several possible specifications, a complete list is given below. Different specification types may have different design methods available. Use DESIGNMETHODS to get a list of design methods available for a given SPEC: designmethods(D). VALUE1, VALUE2, etc. are scalars that provide the value of the corresponding specification. In the example above, this means that Fp = 0.4, Fst = 0.5, Ap = 1, and Ast = 80. Use get(D, 'description') for a description of VALUE1, VALUE2, etc. By default, all frequency specifications are assumed to be in normalized frequency units. Moreover, all magnitude specifications are assumed to be in dB. D = FDESIGN.LOWPASS(...,Fs) provides the sampling frequency of the signal to be filtered. Fs must be specified as a scalar trailing the other numerical values provided. For this case, Fs is assumed to be in Hz as are all other frequency values provided. Note that you don't change the specification string in this case. In the example above, if the input signal is sampled at 8 kHz, we can obtain the same filter by specifying the frequencies in Hz as: D = fdesign.lowpass('Fp,Fst,Ap,Ast',1600,2000,1,80,8000); H = design(D,'equiripple'); D = FDESIGN.LOWPASS(...,MAGUNITS) specifies the units for any magnitude specification given. MAGUNITS can be one of the following: 'linear', 'dB', or 'squared'. If this argument is omitted, 'dB' is assumed. Note that the magnitude specifications are always converted and stored in dB regardless of how they were specified. If Fs is provided, MAGUNITS must be provided after Fs in the input argument list. The full list of possible values for SPECSTRING (not case sensitive) is: 'Fp,Fst,Ap,Ast' (minimum order; default) 'N,F3dB' 'Nb,Na,F3dB' 'N,F3dB,Fst' (*) 'N,F3dB,Ap' (*) 'N,F3dB,Ast' (*) 'N,F3dB,Ap,Ast' (*) 'N,Fc' 'N,Fc,Ap,Ast' 'N,Fp,Ap' 'N,Fp,Ap,Ast' 'N,Fp,F3dB' (*) 'N,Fp,Fst' 'N,Fp,Fst,Ap' (*) 'N,Fp,Fst,Ast' (*) 'N,Fst,Ast' 'N,Fst,Ap,Ast' (*) 'Nb,Na,Fp,Fst' (*) where Ap - Passband Ripple (dB) Ast - Stopband Attenuation (dB) F3dB - 3dB Frequency Fc - Cutoff Frequency Fp - Passband Frequency Fst - Stopband Frequency N - Filter Order Nb - Numerator Order Na - Denominator Order D = FDESIGN.LOWPASS(Fpass, Fstop, Apass, Astop) uses the default SPECSTRING ('Fp,Fst,Ap,Ast') and sets the passband-edge frequency, stopband-edge frequency, passband ripple, and stopband attenuation. % Example #1 - Design a minimum-order equiripple lowpass filter. % Specify ripples in linear units. d = fdesign.lowpass('Fp,Fst,Ap,Ast',0.1,0.12,0.1,1e-4,'linear'); Hd = design(d, 'equiripple'); freqz(Hd) % Example #2 - Design a minimum-phase FIR lowpass filter with % equiripple passband and a stopband that decays as (1/f)^2. (*) d = fdesign.lowpass('N,Fp,Fst',40,0.3,0.35); designopts(d,'equiripple') % List equiripple design options Hd = design(d,'equiripple','StopbandShape','1/f','StopbandDecay',2,... 'minphase',true); freqz(Hd) % Example #3 - Design a Chebyshev Type I IIR filter with a passband % ripple of 0.5 dB and a 3 dB cutoff frequency at 9600 Hz. (*) Fs = 48000; % Sampling frequency of input signal d = fdesign.lowpass('N,F3dB,Ap', 10, 9600, .5, Fs); Hd = design(d, 'cheby1'); freqz(Hd) %(*) DSP System Toolbox required See also FDESIGN, FDESIGN/SETSPECS, FDESIGN/DESIGN, FDESIGN/DESIGNOPTS. Documentation for fdesign.lowpass doc fdesign.lowpass
.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by