design - Apply design method to specification object

Syntax

h = design(d)
h = design(d,designmethod)
h = design(d,designmethod,specname,specvalue,...)

Description

h = design(d) uses specifications object d to generate a filter h. When you do not provide a design method as an input argument, design chooses the design method to use by following these rules in the order listed.

  1. Use equiripple if it applies to the object d.

  2. When equiripple does not apply to d, use another FIR design method, such as firls.

  3. If FIR design methods do not apply to d, use ellip.

  4. When ellip does not apply to d, use another IIR design method, such as butter or cheby2, that applies to the object d.

More rules apply.

For more guidance about using design to design filters, refer to Filter Design Toolbox™ Getting Started Guide . There you find examples that use design to design filters and use methods in the toolbox to analyze them. Alternatively, you can type the following at the MATLAB command prompt to obtain more information:

help design

h = design(d,designmethod) lets you specify a valid design method to design the filter as an input string. Note that the filter returned by design changes depending on the design method you choose. For more information about the filter that a design method returns, refer to the help for the design method.

The design method you provide as the designmethod input argument must be one of the methods returned by

designmethods(d)

for the specifications object d.

Valid entries depend on d. This is the complete set of design methods. The methods that apply to a specific specifications object usually represent a subset of this list.

To help you design filters more quickly, the input argument designmethod accepts a variety of special keywords that force design to behave in different ways. The following table presents the keywords you can use for designmethod and how design responds to the keyword.

Designmethod Keyword

Description of the design Response

fir

Forces design to produce an FIR filter. When no FIR design method exists for object d, design returns an error.

iir

Forces design to produce an IIR filter. When no IIR design method exists for object d, design returns an error.

allfir

Produces filters from every applicable FIR design method for the specifications in d, one filter for each design method. As a result, design returns multiple filters in the output object.

alliir

Produces filters from every applicable IIR design method for the specifications in d, one filter for each design method. As a result, design returns multiple filters in the output object.

all

Designs filters using all applicable design methods for the specifications object d. As a result, design returns multiple filters, one for each design method. design uses the design methods in the order that designmethods(d) returns them. Refer to Examples to see this in use.

Keywords are not case sensitive and must be enclosed in single quotation marks like any string input.

When design returns multiple filters in the output object, use indexing to see the individual filters. For example, to see the third filter in h, enter

h(3)

at the MATLAB prompt.

h = design(d,designmethod,specname,specvalue,...) with this syntax you can specify not only the design method but also values for the filter specifications in the method. Provide the specifications in the order of the name of the specification, such as the FilterOrder, followed by the value to assign to the specification. Enter as many specname/specvalue pairs as you need to define your filter. Any specification you do not define uses the default specification value. To use the specname/specvalue syntax, you must provide the design method to use in designmethod.

Examples

To demonstrate some of the design options, these examples use a few different input arguments and output arguments. For the first example, use design to return the default filter based on the default design method equiripple.

d = fdesign.lowpass(.2,.22);
hd = design(d) % Uses the default equiripple method.

hd =
 
     FilterStructure: 'Direct-Form FIR'
          Arithmetic: 'double'         
           Numerator: [1x202 double]   
    PersistentMemory: false            

In this example, use the allfir keyword with design to return an FIR filter for each valid design method for the specifications in specifications object d.

designmethods(d)


Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast):


butter
cheby1
cheby2
ellip
equiripple
ifir
kaiserwin
multistage

hallfir=design(d,'allfir')
 
hallfir =
 
	dfilt.basefilter: 1-by-4    

hallfir contains filters designed using the ellip, equiripple, ifir, and multistage design methods, in the order shown by designmethods(d). The first filter in hallfir comes from the ellip design method; the second from the equiripple method; the third from using ifir to design the filter; and the fourth from using multistage.

To see an individual filter, use an index with the filter object. For example, to see the second filter in hallfir, enter hallfir(2)

hallfir(2)
 
ans =
 
     FilterStructure: Cascade
            Stage(1): Direct-Form FIR
            Stage(2): Direct-Form FIR
    PersistentMemory: false

Here is the multistage filter hallfir(4)

hallfir(4)
 
ans =
 
 FilterStructure: Cascade
      Stage(1): Direct-Form FIR Polyphase Decimator
      Stage(2): Direct-Form FIR Polyphase Decimator
      Stage(3): Direct-Form FIR Polyphase Decimator
      Stage(4): Direct-Form FIR Polyphase Interpolator
      Stage(5): Direct-Form FIR Polyphase Interpolator
      Stage(6): Direct-Form FIR Polyphase Interpolator
PersistentMemory: false

This final example uses equiripple to design an FIR filter with the density factor set to 20 by using the specname/specvalue syntax.

[hd,res,err] = design(d,'equiripple','densityfactor',20);
hd
 
hd =
 
     FilterStructure: 'Direct-Form FIR'
          Arithmetic: 'double'         
           Numerator: [1x202 double]   
    PersistentMemory: false            
res

res =

    0.9903

err

err = 

         order: 201
         fgrid: [2060x1 double]
             H: [2060x1 double]
         error: [2060x1 double]
           des: [2060x1 double]
            wt: [2060x1 double]
         iextr: [102x1 double]
         fextr: [102x1 double]
    iterations: 12
         evals: 12905
     edgeCheck: [4x1 double]
    returnCode: 0

res and err are optional output arguments that design returns when you specify the density factor with the equiripple design method.

See Also

designmethods, butter, cheby1, cheby2, ellip, equiripple, firls, fdesign.halfband, kaiserwin, fdesign.nyquist, fdesign.rsrc

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS