use filter designer with dsp system toolbox software -凯发k8网页登录

main content

use filter designer with dsp system toolbox software

design advanced filters in filter designer

overview of filter designer features

dsp system toolbox™ software adds new dialog boxes and operating modes, and new menu selections, to the filter designer provided by signal processing toolbox™ software. from the additional dialog boxes, one titled set quantization parameters and one titled frequency transformations, you can:

  • design advanced filters that signal processing toolbox software does not provide the design tools to develop.

  • view simulink® models of the filter structures available in the toolbox.

  • quantize double-precision filters you design in this app using the design mode.

  • quantize double-precision filters you import into this app using the import mode.

  • analyze quantized filters.

  • scale second-order section filters.

  • select the quantization settings for the properties of the quantized filter displayed by the tool:

    • coefficients — select the quantization options applied to the filter coefficients

    • input/output — control how the filter processes input and output data

    • filter internals — specify how the arithmetic for the filter behaves

  • design multirate filters.

  • transform both fir and iir filters from one response to another.

after you import a filter into filter designer, the options on the quantization dialog box let you quantize the filter and investigate the effects of various quantization settings.

options in the frequency transformations dialog box let you change the frequency response of your filter, keeping various important features while changing the response shape.

use filter designer with dsp system toolbox software

adding dsp system toolbox software to your tool suite adds a number of filter design techniques to filter designer. use the new filter responses to develop filters that meet more complex requirements than those you can design in signal processing toolbox software. while the designs in filter designer are available as command line functions, the graphical user interface of filter designer makes the design process more clear and easier to accomplish.

as you select a response type, the options in the right panes in filter designer change to let you set the values that define your filter. you also see that the analysis area includes a diagram (called a design mask) that describes the options for the filter response you choose.

by reviewing the mask you can see how the options are defined and how to use them. while this is usually straightforward for lowpass or highpass filter responses, setting the options for the arbitrary response types or the peaking/notching filters is more complicated. having the masks leads you to your result more easily.

changing the filter design method changes the available response type options. similarly, the response type you select may change the filter design methods you can choose.

design a notch filter

notch filters aim to remove one or a few frequencies from a broader spectrum. you must specify the frequencies to remove by setting the filter design options in filter designer appropriately:

  • response type

  • design method

  • frequency specifications

  • magnitude specifications

here is how you design a notch filter that removes concert a (440 hz) from an input musical signal spectrum.

  1. select notching from the differentiator list in response type.

  2. select iir in filter design method and choose single notch from the list.

  3. for the frequency specifications, set units to hz and fs, the full scale frequency, to 1000.

  4. set the location of the center of the notch, in either normalized frequency or hz. for the notch center at 440 hz, enter 440.

  5. to shape the notch, enter the bandwidth, bw, to be 40.

  6. leave the magnitude specification in db (the default) and leave apass as 1.

  7. click design filter.

    filter designer computes the filter coefficients and plots the filter magnitude response in the analysis area for you to review.

when you design a single notch filter, you do not have the option of setting the filter order — the filter order options are disabled.

your filter should look about like this:

for more information about a design method, refer to the online help system. for instance, to get further information about the q setting for the notch filter in filter designer, enter

doc iirnotch

at the command line. this opens the help browser and displays the reference page for function iirnotch.

designing other filters follows a similar procedure, adjusting for different design specification options as each design requires.

any one of the designs may be quantized in filter designer and analyzed with the available analyses on the analysis menu.

access the quantization features of filter designer

you use the quantization panel in filter designer to quantize filters. quantization represents the fourth operating mode for filter designer, along with the filter design, filter transformation, and import modes. to switch to quantization mode, open filter designer from the matlab® command prompt by entering

filterdesigner

when filter designer opens, click the set quantization parameters button on the side bar. filter designer switches to quantization mode and you see the following panel at the bottom of filter designer, with the default double-precision option shown for filter arithmetic.

the filter arithmetic option lets you quantize filters and investigate the effects of changing quantization settings. to enable the quantization settings in filter designer, select fixed-point from the filter arithmetic.

the quantization options appear in the lower panel of filter designer. you see tabs that access various sets of options for quantizing your filter.

you use the following tabs in the dialog box to perform tasks related to quantizing filters in filter designer:

  • coefficients provides access the settings for defining the coefficient quantization. this is the default active panel when you switch filter designer to quantization mode without a quantized filter in the tool. when you import a fixed-point filter into filter designer, this is the active pane when you switch to quantization mode.

  • input/output switches filter designer to the options for quantizing the inputs and outputs for your filter.

  • filter internals lets you set a variety of options for the arithmetic your filter performs, such as how the filter handles the results of multiplication operations or how the filter uses the accumulator.

  • apply — applies changes you make to the quantization parameters for your filter.

quantize filters in filter designer

set quantization parameters

quantized filters have properties that define how they quantize data you filter. use the set quantization parameters dialog box in filter designer to set the properties. using options in the set quantization parameters dialog box, filter designer lets you perform a number of tasks:

  • create a quantized filter from a double-precision filter after either importing the filter from your workspace, or using filter designer to design the prototype filter.

  • create a quantized filter that has the default structure (direct form ii transposed) or any structure you choose, and other property values you select.

  • change the quantization property values for a quantized filter after you design the filter or import it from your workspace.

when you click set quantization parameters, and then change filter arithmetic to fixed-point, the quantized filter panel opens in filter designer, with the coefficient quantization options set to default values.

coefficients options

to let you set the properties for the filter coefficients that make up your quantized filter, filter designer lists options for numerator word length (and denominator word length if you have an iir filter). the following table lists each coefficients option and a short description of what the option setting does in the filter.

option name

when used

description

numerator word length

fir filters only

sets the word length used to represent numerator coefficients in fir filters.

numerator frac. length

fir/iir

sets the fraction length used to interpret numerator coefficients in fir filters.

numerator range ( /-)

fir/iir

lets you set the range the numerators represent. you use this instead of the numerator frac. length option to set the precision. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

coefficient word length

iir filters only

sets the word length used to represent both numerator and denominator coefficients in iir filters. you cannot set different word lengths for the numerator and denominator coefficients.

denominator frac. length

iir filters

sets the fraction length used to interpret denominator coefficients in iir filters.

denominator range ( /-)

iir filters

lets you set the range the denominator coefficients represent. you use this instead of the denominator frac. length option to set the precision. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

best-precision fraction lengths

all filters

directs filter designer to select the fraction lengths for numerator (and denominator where available) values to maximize the filter performance. selecting this option disables all of the fraction length options for the filter.

scale values frac. length

sos iir filters

sets the fraction length used to interpret the scale values in sos filters.

scale values range ( /-)

sos iir filters

lets you set the range the sos scale values represent. you use this with sos filters to adjust the scaling used between filter sections. setting this value disables the scale values frac. length option. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

use unsigned representation

all filters

tells filter designer to interpret the coefficients as unsigned values.

scale the numerator coefficients to fully utilize the entire dynamic range

all filters

directs filter designer to scale the numerator coefficients to effectively use the dynamic range defined by the numerator word length and fraction length format.

input/output options

the options that specify how the quantized filter uses input and output values are listed in the table below.

option name

when used

description

input word length

all filters

sets the word length used to represent the input to a filter.

input fraction length

all filters

sets the fraction length used to interpret input values to filter.

input range ( /-)

all filters

lets you set the range the inputs represent. you use this instead of the input fraction length option to set the precision. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

output word length

all filters

sets the word length used to represent the output from a filter.

avoid overflow

all filters

directs the filter to set the fraction length for the input to prevent the output values from exceeding the available range as defined by the word length. clearing this option lets you set output fraction length.

output fraction length

all filters

sets the fraction length used to represent output values from a filter.

output range ( /-)

all filters

lets you set the range the outputs represent. you use this instead of the output fraction length option to set the precision. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

stage input word length

sos filters only

sets the word length used to represent the input to an sos filter section.

avoid overflow

sos filters only

directs the filter to use a fraction length for stage inputs that prevents overflows in the values. when you clear this option, you can set stage input fraction length.

stage input fraction length

sos filters only

sets the fraction length used to represent input to a section of an sos filter.

stage output word length

sos filters only

sets the word length used to represent the output from an sos filter section.

avoid overflow

sos filters only

directs the filter to use a fraction length for stage outputs that prevents overflows in the values. when you clear this option, you can set stage output fraction length.

stage output fraction length

sos filters only

sets the fraction length used to represent the output from a section of an sos filter.

filter internals options

the options that specify how the quantized filter performs arithmetic operations are listed in the table below.

option

equivalent filter property (using wildcard *)

description

round towards

roundmode

sets the mode the filter uses to quantize numeric values when the values lie between representable values for the data format (word and fraction lengths). choose from one of:

  • ceil - round toward positive infinity.

  • convergent - round to the closest representable integer. ties round to the nearest even stored integer. this is the least biased of the methods available in this software.

  • fix/zero - round toward zero.

  • floor - round toward negative infinity.

  • nearest - round toward nearest. ties round toward positive infinity.

  • round - round toward nearest. ties round toward negative infinity for negative numbers, and toward positive infinity for positive numbers.

overflow mode

overflowmode

sets the mode used to respond to overflow conditions in fixed-point arithmetic. choose from either saturate (limit the output to the largest positive or negative representable value) or wrap (set overflowing values to the nearest representable value using modular arithmetic.

filter product (multiply) options

product mode

productmode

determines how the filter handles the output of product operations. choose from full precision (fullprecision), or whether to keep the most significant bit (keepmsb) or least significant bit (keeplsb) in the result when you need to shorten the word length. specify all lets you set the fraction length applied to the results of product operations.

product word length

*prodwordlength

sets the word length applied to interpret the results of multiply operations.

num. fraction length

numprodfraclength

sets the fraction length used to interpret the results of product operations that involve numerator coefficients.

den. fraction length

denprodfraclength

sets the fraction length used to interpret the results of product operations that involve denominator coefficients.

filter sum options

accum. mode

accummode

determines how the accumulator outputs stored values. choose from full precision (fullprecision), or whether to keep the most significant bits (keepmsb) or least significant bits (keeplsb) when output results need shorter word length than the accumulator supports. to let you set the word length and the precision (the fraction length) used by the output from the accumulator, set this to specify all.

accum. word length

*accumwordlength

sets the word length used to store data in the accumulator/buffer.

num. fraction length

numaccumfraclength

sets the fraction length used to interpret the numerator coefficients.

den. fraction length

denaccumfraclength

sets the fraction length the filter uses to interpret denominator coefficients.

cast signals before sum

castbeforesum

specifies whether to cast numeric data to the appropriate accumulator format (as shown in the signal flow diagrams for each filter structure) before performing sum operations.

filter state options

state word length

*statewordlength

sets the word length used to represent the filter states. applied to both numerator- and denominator-related states

avoid overflow

none

prevent overflows in arithmetic calculations by setting the fraction length appropriately.

state fraction length

*statefraclength

lets you set the fraction length applied to interpret the filter states. applied to both numerator- and denominator-related states

note

when you apply changes to the values in the filter internals pane, the plots for the magnitude response estimate and round-off noise power spectrum analyses update to reflect those changes. other types of analyses are not affected by changes to the values in the filter internals pane.

filter internals options for cic filters

cic filters use slightly different options for specifying the fixed-point arithmetic in the filter. the next table shows and describes the options.

quantize double-precision filters.  when you are quantizing a double-precision filter by switching to fixed-point or single-precision floating point arithmetic, follow these steps.

  1. click set quantization parameters to display the set quantization parameters pane in filter designer.

  2. select single-precision floating point or fixed-point from filter arithmetic.

    when you select one of the optional arithmetic settings, filter designer quantizes the current filter according to the settings of the options in the set quantization parameter panes, and changes the information displayed in the analysis area to show quantized filter data.

  3. in the quantization panes, set the options for your filter. set options for coefficients, input/output, and filter internals.

  4. click apply.

    filter designer quantizes your filter using your new settings.

  5. use the analysis features in filter designer to determine whether your new quantized filter meets your requirements.

change the quantization properties of quantized filters.  when you are changing the settings for the quantization of a quantized filter, or after you import a quantized filter from your matlab workspace, follow these steps to set the property values for the filter:

  1. verify that the current filter is quantized.

  2. click set quantization parameters to display the set quantization parameters panel.

  3. review and select property settings for the filter quantization: coefficients, input/output, and filter internals. settings for options on these panes determine how your filter quantizes data during filtering operations.

  4. click apply to update your current quantized filter to use the new quantization property settings from step 3.

  5. use the analysis features in filter designer to determine whether your new quantized filter meets your requirements.

analyze filters with a noise-based method

analyze filters with the magnitude response estimate method

after you design and quantize your filter, the magnitude response estimate option on the analysis menu lets you apply the noise loading method to your filter. when you select analysis > magnitude response estimate from the menu bar, filter designer immediately starts the monte carlo trials that form the basis for the method and runs the analysis, ending by displaying the results in the analysis area in filter designer.

with the noise-based method, you estimate the complex frequency response for your filter as determined by applying a noise- like signal to the filter input. magnitude response estimate uses the monte carlo trials to generate a noise signal that contains complete frequency content across the range 0 to fs. the first time you run the analysis, magnitude response estimate uses default settings for the various conditions that define the process, such as the number of test points and the number of trials.

analysis parameter

default setting

description

number of points

512

number of equally spaced points around the upper half of the unit circle.

frequency range

0 to fs/2

frequency range of the plot x-axis.

frequency units

hz

units for specifying the frequency range.

sampling frequency

48000

inverse of the sampling period.

frequency scale

db

units used for the y-axis display of the output.

normalized frequency

off

use normalized frequency for the display.

after your first analysis run ends, open the analysis parameters dialog box and adjust your settings appropriately, such as changing the number of trials or number of points.

to open the analysis parameters dialog box, use either of the next procedures when you have a quantized filter in filter designer:

  • select analysis > analysis parameters from the menu bar

  • right-click in the filter analysis area and select analysis parameters from the context menu

whichever option you choose opens the dialog box. notice that the settings for the options reflect the defaults.

noise method applied to a filter.  to demonstrate the magnitude response estimate method, start by creating a quantized filter. for this example, use filter designer to design a sixth-order butterworth iir filter.

to use noise-based analysis in filter designer

  1. enter filterdesigner at the matlab prompt to launch filter designer.

  2. under response type, select highpass.

  3. select iir in design method. then select butterworth.

  4. to set the filter order to 6, select specify order under filter order. enter 6 in the text box.

  5. click design filter.

    in filter designer, the analysis area changes to display the magnitude response for your filter.

  6. to generate the quantized version of your filter, using default quantizer settings, click on the side bar.

    filter designer switches to quantization mode and displays the quantization panel.

  7. from filter arithmetic, select fixed-point.

    now the analysis areas shows the magnitude response for both filters — your original filter and the fixed-point arithmetic version.

  8. finally, to use noise-based estimation on your quantized filter, select analysis > magnitude response estimate from the menu bar.

    filter designer runs the trial, calculates the estimated magnitude response for the filter, and displays the result in the analysis area as shown in this figure.

    in the above figure you see the magnitude response as estimated by the analysis method.

view the noise power spectrum.  when you use the noise method to estimate the magnitude response of a filter, filter designer simulates and applies a spectrum of noise values to test your filter response. while the simulated noise is essentially white, you might want to see the actual spectrum that filter designer used to test your filter.

from the analysis menu bar option, select round-off noise power spectrum. in the analysis area in filter designer, you see the spectrum of the noise used to estimate the filter response. the details of the noise spectrum, such as the range and number of data points, appear in the analysis parameters dialog box.

for more information, refer to mcclellan, et al., computer-based exercises for signal processing using matlab 5, prentice-hall, 1998. see project 5: quantization noise in digital filters, page 231.

change your noise analysis parameters.  in noise method applied to a filter, you used synthetic white noise to estimate the magnitude response for a fixed-point highpass butterworth filter. since you ran the estimate only once in filter designer, your noise analysis used the default analysis parameters settings shown in analyze filters with the magnitude response estimate method.

to change the settings, follow these steps after the first time you use the noise estimate on your quantized filter.

  1. with the results from running the noise estimating method displayed in the filter designer analysis area, select analysis > analysis parameters from the menu bar.

    to give you access to the analysis parameters, the analysis parameters dialog box opens (with default settings).

  2. to use more points in the spectrum to estimate the magnitude response, change number of points to 1024 and click ok to run the analysis.

    filter designer closes the analysis parameters dialog box and reruns the noise estimate, returning the results in the analysis area.

    to rerun the test without closing the dialog box, press enter after you type your new value into a setting, then click apply. now filter designer runs the test without closing the dialog box. when you want to try many different settings for the noise-based analysis, this is a useful shortcut.

compare the estimated and theoretical magnitude responses

an important measure of the effectiveness of the noise method for estimating the magnitude response of a quantized filter is to compare the estimated response to the theoretical response.

one way to do this comparison is to overlay the theoretical response on the estimated response. while you have the magnitude response estimate displaying in filter designer, select analysis > overlay analysis from the menu bar. then select magnitude response to show both response curves plotted together in the analysis area.

select quantized filter structures

filter designer lets you change the structure of any quantized filter. use the convert structure option to change the structure of your filter to one that meets your needs.

to learn about changing the structure of a filter in filter designer, refer to .

convert the structure of a quantized filter

you use the convert structure option to change the structure of filter. when the source is designed(quantized) or imported(quantized), convert structure lets you recast the filter to one of the following structures:

  • direct form ii transposed filter structure

  • direct form i transposed filter structure

  • direct form ii filter structure

  • direct form i filter structure

  • direct form finite impulse response (fir) filter structure

  • direct form fir transposed filter structure

  • lattice autoregressive moving average (arma) filter structure

  • direct form antisymmetric fir filter structure (any order)

starting from any quantized filter, you can convert to one of the following representation:

  • direct form i

  • direct form ii

  • direct form i transposed

  • direct form ii transposed

  • lattice arma

additionally, filter designer lets you do the following conversions:

  • minimum phase fir filter to lattice ma minimum phase

  • maximum phase fir filter to lattice ma maximum phase

  • allpass filters to lattice allpass

convert filters to second-order sections form

to learn about using filter designer to convert your quantized filter to use second-order sections, refer to . you might notice that filters you design in filter designer, rather than filters you imported, are implemented in sos form.

view filter structures in filter designer.  to open the demonstration, click help > show filter structure. after the help browser opens, you see the reference page for the current filter. you find the filter structure signal flow diagram on this reference page, or you can navigate to reference pages for other filter.

scale second-order section filters

use the reordering and scaling of second-order sections dialog box

filter designer provides the ability to scale sos filters after you create them. using options on the reordering and scaling of second-order sections dialog box, filter designer scales either or both the filter numerators and filter scale values according to your choices for the scaling options.

parameter

description and valid value

scale

apply any scaling options to the filter. select this when you are reordering your sos filter and you want to scale it at the same time. or when you are scaling your filter, with or without reordering. scaling is disabled by default.

less overflow — highest snr slider

lets you set whether scaling favors reducing arithmetic overflow in the filter or maximizing the signal-to-noise ratio (snr) at the filter output. moving the slider to the right increases the emphasis on snr at the expense of possible overflows. the markings indicate the p-norm applied to achieve the desired result in snr or overflow protection.

maximum numerator

maximum allowed value for numerator coefficients after scaling.

numerator constraint

specifies whether and how to constrain numerator coefficient values. options are none, normalize, power of 2, and unit. choosing none lets the scaling use any scale value for the numerators by removing any constraints on the numerators, except that the coefficients will be clipped if they exceed the maximum numerator. with normalize the maximum absolute value of the numerator is forced to equal the maximum numerator value (for all other constraints, the maximum numerator is only an upper limit, above which coefficients will be clipped). the power of 2 option forces scaling to use numerator values that are powers of 2, such as 2 or 0.5. with unit, the leading coefficient of each numerator is forced to a value of 1.

overflow mode

sets the way the filter handles arithmetic overflow situations during scaling. choose from either saturate (limit the output to the largest positive or negative representable value) or wrap (set overflowing values to the nearest representable value using modular arithmetic.

scale value constraint

specify whether to constrain the filter scale values, and how to constrain them. valid options are unit, power of 2, and none. choosing unit for the constraint disables the max scale value setting and forces scale values to equal 1. power of 2 constrains the scale values to be powers of 2, such as 2 or 0.5, while none removes any constraint on the scale values, except that they cannot exceed the max scale value.

max scale value

sets the maximum allowed scale values. sos filter scaling applies the max scale value limit only when you set scale value constraint to a value other than unit (the default setting). setting a maximum scale value removes any other limits on the scale values.

revert to original filter

returns your filter to the original scaling. being able to revert to your original filter makes it easier to assess the results of scaling your filter.

various combinations of settings let you scale filter numerators without changing the scale values, or adjust the filter scale values without changing the numerators. there is no scaling control for denominators.

scale an sos filter

start the process by designing a lowpass elliptical filter in filter designer.

  1. launch filter designer.

  2. in response type, select lowpass.

  3. in design method, select iir and elliptic from the iir design methods list.

  4. select minimum order for the filter.

  5. switch the frequency units by choosing normalized(0 to 1) from the units list.

  6. to set the passband specifications, enter 0.45 for wpass and 0.55 for wstop. finally, in magnitude specifications, set astop to 60.

  7. click design filter to design the filter.

    after filter designer finishes designing the filter, you see the following plot and settings in the tool.

    you kept the options setting for match exactly as both, meaning the filter design matches the specification for the passband and the stopband.

  8. to switch to scaling the filter, select edit > reorder and scale second-order sections from the menu bar.

  9. to see the filter coefficients, return to filter designer and select filter coefficients from the analysis menu. filter designer displays the coefficients and scale values in filter designer.

with the coefficients displayed you can see the effects of scaling your filter directly in the scale values and filter coefficients.

now try scaling the filter in a few different ways. first scale the filter to maximize the snr.

  1. return to the reordering and scaling second-order sections dialog box and select none for reordering in the left pane. this prevents filter designer from reordering the filter sections when you rescale the filter.

  2. move the less overflow—highest snr slider from less overflow to highest snr.

  3. click apply to scale the filter and leave the dialog box open.

    after a few moments, filter designer updates the coefficients displayed so you see the new scaling.

    all of the scale factors are now 1, and the sos matrix of coefficients shows that none of the numerator coefficients are 1 and the first denominator coefficient of each section is 1.

  4. click revert to original filter to restore the filter to the original settings for scaling and coefficients.

reorder the sections of second-order section filters

reorder filters using filter designer

filter designer designs most discrete-time filters in second-order sections. generally, sos filters resist the effects of quantization changes when you create fixed-point filters. after you have a second-order section filter in filter designer, either one you designed in the tool, or one you imported, filter designer provides the capability to change the order of the sections that compose the filter. any sos filter in filter designer allows reordering of the sections.

to reorder the sections of a filter, you access the reorder and scaling of second-order sections dialog box in filter designer.

with your sos filter in filter designer, select edit > reorder and scale from the menu bar. filter designer returns the reordering dialog box shown here with the default settings.

controls on the reordering and scaling of second-order sections dialog box

in this dialog box, the left-hand side contains options for reordering sos filters. on the right you see the scaling options. these are independent — reordering your filter does not require scaling (note the scale option) and scaling does not require that you reorder your filter (note the none option under reordering). for more about scaling sos filters, refer to scale second-order section filters and to in the reference section.

reordering sos filters involves using the options in the reordering and scaling of second-order sections dialog box. the following table lists each reorder option and provides a description of what the option does.

control option

description

auto

reorders the filter sections to minimize the output noise power of the filter. note that different ordering applies to each specification type, such as lowpass or highpass. automatic ordering adapts to the specification type of your filter.

none

does no reordering on your filter. selecting none lets you scale your filter without applying reordering at the same time. when you access this dialog box with a current filter, this is the default setting — no reordering is applied.

least selective section to most selective section

rearranges the filter sections so the least restrictive (lowest q) section is the first section and the most restrictive (highest q) section is the last section.

most selective section to least selective section

rearranges the filter sections so the most restrictive (highest q) section is the first section and the least restrictive (lowest q) section is the last section.

custom reordering

lets you specify the section ordering to use by enabling the numerator order and denominator order options

numerator order

specify new ordering for the sections of your sos filter. enter a vector of the indices of the sections in the order in which to rearrange them. for example, a filter with five sections has indices 1, 2, 3, 4, and 5. to switch the second and fourth sections, the vector would be [1,4,3,2,5].

use numerator order

rearranges the denominators in the order assigned to the numerators.

specify

lets you specify the order of the denominators, rather than using the numerator order. enter a vector of the indices of the sections to specify the order of the denominators to use. for example, a filter with five sections has indices 1, 2, 3, 4, and 5. to switch the second and fourth sections, the vector would be [1,4,3,2,5].

use numerator order

reorders the scale values according to the order of the numerators.

specify

lets you specify the order of the scale values, rather than using the numerator order. enter a vector of the indices of the sections to specify the order of the denominators to use. for example, a filter with five sections has indices 1, 2, 3, 4, and 5. to switch the second and fourth sections, the vector would be [1,4,3,2,5].

revert to original filter

returns your filter to the original section ordering. being able to revert to your original filter makes comparing the results of changing the order of the sections easier to assess.

reorder an sos filter.  with filter designer open a second-order filter as the current filter, you use the following process to access the reordering capability and reorder you filter. start by launching filter designer from the command prompt.

  1. enter filterdesigner at the command prompt to launch filter designer.

  2. design a lowpass butterworth filter with order 10 and the default frequency specifications by entering the following settings:

    • under response type select lowpass.

    • under design method, select iir and butterworth from the list.

    • specify the order equal to 10 in specify order under filter order.

    • keep the default fs and fc values in frequency specifications.

  3. click design filter.

    filter designer designs the butterworth filter and returns your filter as a direct-form ii filter implemented with second-order sections. you see the specifications in the current filter information area.

    with the second-order filter in filter designer, reordering the filter uses the reordering and scaling of second-order sections feature in filter designer (also available in filter visualization tool, ).

  4. to reorder your filter, select edit > reorder and scale second-order sections from the filter designer menus.

now you are ready to reorder the sections of your filter. note that filter designer performs the reordering on the current filter in the session.

use least selective to most selective section reordering.  to let filter designer reorder your filter so the least selective section is first and the most selective section is last, perform the following steps in the reordering and scaling of second-order sections dialog box.

  1. in reordering, select least selective section to most selective section.

  2. to prevent filter scaling at the same time, clear scale in scaling.

  3. in filter designer, select view > sos view settings from the menu bar so you see the sections of your filter displayed in filter designer.

  4. in the sos view settings dialog box, select individual sections. making this choice configures filter designer to show the magnitude response curves for each section of your filter in the analysis area.

  5. back in the reordering and scaling of second-order sections dialog box, click apply to reorder your filter according to the qs of the filter sections, and keep the dialog box open. in response, filter designer presents the responses for each filter section (there should be five sections) in the analysis area.

    in the next two figures you can compare the ordering of the sections of your filter. in the first figure, your original filter sections appear. in the second figure, the sections have been rearranged from least selective to most selective.

you see what reordering does, although the result is a bit subtle. now try custom reordering the sections of your filter or using the most selective to least selective reordering option.

view sos filter sections

using the sos view dialog box

since you can design and reorder the sections of sos filters, filter designer provides the ability to view the filter sections in the analysis area — sos view. once you have a second-order section filter as your current filter in filter designer, you turn on the sos view option to see the filter sections individually, or cumulatively, or even only some of the sections. enabling sos view puts filter designer in a mode where all second-order section filters display sections until you disable the sos view option. sos view mode applies to any analysis you display in the analysis area. for example, if you configure filter designer to show the phase responses for filters, enabling sos view means filter designer displays the phase response for each section of sos filters.

controls on the sos view dialog box

sos view uses a few options to control how filter designer displays the sections, or which sections to display. when you select view > sos view from the filter designer menu bar, you see this dialog box containing options to configure sos view operation.

by default, sos view shows the overall response of sos filters. options in the sos view dialog box let you change the display. this table lists all the options and describes the effects of each.

option

description

overall filter

this is the familiar display in filter designer. for a second-order section filter you see only the overall response rather than the responses for the individual sections. this is the default configuration.

individual sections

when you select this option, filter designer displays the response for each section as a curve. if your filter has five sections you see five response curves, one for each section, and they are independent. compare to cumulative sections.

cumulative sections

when you select this option, filter designer displays the response for each section as the accumulated response of all prior sections in the filter. if your filter has five sections you see five response curves:

  • the first curve plots the response for the first filter section.

  • the second curve plots the response for the combined first and second sections.

  • the third curve plots the response for the first, second, and third sections combined.

and so on until all filter sections appear in the display. the final curve represents the overall filter response. compare to cumulative sections and overall filter.

user defined

here you define which sections to display, and in which order. selecting this option enables the text box where you enter a cell array of the indices of the filter sections. each index represents one section. entering one index plots one response. entering something like {1:2} plots the combined response of sections 1 and 2. if you have a filter with four sections, the entry {1:4} plots the combined response for all four sections, whereas {1,2,3,4} plots the response for each section. note that after you enter the cell array, you need to click ok or apply to update the filter designer analysis area to the new sos view configuration.

use secondary-scaling points

this directs filter designer to use the secondary scaling points in the sections to determine where to split the sections. this option applies only when the filter is a df2sos or df1tsos filter. for these structures, the secondary scaling points refer to the scaling locations between the recursive and the nonrecursive parts of the section (the "middle" of the section). by default, secondary-scaling points is not enabled. you use this with the cumulative sections option only.

view the sections of sos filters

after you design or import an sos filter in to filter designer, the sos view option lets you see the per section performance of your filter. enabling sos view from the view menu in filter designer configures the tool to display the sections of sos filters whenever the current filter is an sos filter.

these next steps demonstrate using sos view to see your filter sections displayed in filter designer.

  1. launch filter designer.

  2. create a lowpass sos filter using the butterworth design method. specify the filter order to be 6. using a low order filter makes seeing the sections more clear.

  3. design your new filter by clicking design filter.

    filter designer design your filter and show you the magnitude response in the analysis area. in current filter information you see the specifications for your filter. you should have a sixth-order direct-form ii, second-order sections filter with three sections.

  4. to enable sos view, select view > sos view from the menu bar.

    by default the analysis area in filter designer shows the overall filter response, not the individual filter section responses. this dialog box lets you change the display configuration to see the sections.

  5. to see the magnitude responses for each filter section, select individual sections.

  6. click apply to update filter designer to display the responses for each filter section. the analysis area changes to show you something like the following figure.

    if you switch filter designer to display filter phase responses (by selecting analysis > phase response), you see the phase response for each filter section in the analysis area.

  7. to define your own display of the sections, you use the user defined option and enter a vector of section indices to display. now you see a display of the first section response, and the cumulative first, second, and third sections response:

    • select user defined to enable the text entry box in the dialog box.

    • enter the cell array {1,1:3} to specify that filter designer should display the response of the first section and the cumulative response of the first three sections of the filter.

  8. to apply your new sos view selection, click apply or ok (which closes the sos view dialog box).

    in the filter designer analysis area you see two curves — one for the response of the first filter section and one for the combined response of sections 1, 2, and 3.

import and export quantized filters

overview and structures

when you import a quantized filter into filter designer, or export a quantized filter from filter designer to your workspace, the import and export functions use objects and you specify the filter as a variable. this contrasts with importing and exporting nonquantized filters, where you select the filter structure and enter the filter numerator and denominator for the filter transfer function.

you have the option of exporting quantized filters to your matlab workspace, exporting them to text files, or exporting them to mat-files.

for general information about importing and exporting filters in filter designer, refer to , and .

filter designer imports quantized filters having the following structures:

  • direct form i

  • direct form ii

  • direct form i transposed

  • direct form ii transposed

  • direct form symmetric fir

  • direct form antisymmetric fir

  • lattice allpass

  • lattice ar

  • lattice ma minimum phase

  • lattice ma maximum phase

  • lattice arma

  • lattice coupled-allpass

  • lattice coupled-allpass power complementary

import quantized filters

after you design or open a quantized filter in your matlab workspace, filter designer lets you import the filter for analysis. follow these steps to import your filter in to filter designer:

  1. open filter designer.

  2. select file > import filter from workspace from the menu bar, or choose the import filter from workspace icon in the side panel:

    .

    in the lower region of filter designer, the design filter pane becomes import filter, and options appear for importing quantized filters, as shown.

  3. from the filter structure list, select filter object.

    the options for importing filters change to include:

    • discrete filter — enter the variable name for the discrete-time, fixed-point filter in your workspace.

    • frequency units — select the frequency units from the units list under sampling frequency, and specify the sampling frequency value in fs if needed. your sampling frequency must correspond to the units you select. for example, when you select normalized (0 to 1), fs defaults to one. but if you choose one of the frequency options, enter the sampling frequency in your selected units. if you have the sampling frequency defined in your workspace as a variable, enter the variable name for the sampling frequency.

  4. click import to import the filter.

    filter designer checks your workspace for the specified filter. it imports the filter if it finds it, displaying the magnitude response for the filter in the analysis area. if it cannot find the filter it returns an filter designer error dialog box.

note

if, during any filter designer session, you switch to quantization mode and create a fixed-point filter, filter designer remains in quantization mode. if you import a double-precision filter, filter designer automatically quantizes your imported filter applying the most recent quantization parameters.
when you check the current filter information for your imported filter, it will indicate that the filter is source: imported (quantized) even though you did not import a quantized filter.

to export quantized filters

to save your filter design, filter designer lets you export the quantized filter to your matlab workspace (or you can save the current session in filter designer). when you choose to save the quantized filter by exporting it, you select one of these options:

export coefficients, objects, or system objects to the workspace.  you can save the filter as filter coefficients variables or filter system object™ variables.

to save the filter to the matlab workspace:

  1. select export from the file menu. the export dialog box appears.

  2. select workspace from the export to list.

  3. from the export as list, select one of the following options:

    • select coefficients to save the filter coefficients.

    • select system objects to save the filter in a filter system object.

    the system objects option does not appear in the drop-down list when the current filter structure is not supported by system objects.

  4. assign a variable name:

    • for coefficients, assign variable names using the numerator and denominator options under variable names.

    • for system objects, assign the variable name in the discrete filter option.

    if you have variables with the same names in your workspace and you want to overwrite them, select the overwrite variables box.

  5. click export.

    do not try to export the filter to a variable name that exists in your workspace without selecting overwrite variables, in the previous step. if you do so, filter designer stops the export operation. the tool returns a warning that the variable you specified as the quantized filter name already exists in the workspace.

    • to continue to export the filter to the existing variable, click ok to dismiss the warning.

    • then select the overwrite variables check box and click export.

export filter coefficients as a text file.  to save your quantized filter as a text file, follow these steps:

  1. select export from the file menu.

  2. select text-file under export to.

  3. click ok to export the filter and close the dialog box. click apply to export the filter without closing the export dialog box. clicking apply lets you export your quantized filter to more than one name without leaving the export dialog box.

    the export filter coefficients to text-file dialog box appears. this is the standard microsoft windows® save file dialog box.

  4. choose or enter a folder and filename for the text file, and click ok.

    filter designer exports your quantized filter as a text file with the name you provided, and the matlab editor opens, displaying the file for editing.

export filter coefficients as a mat-file.  to save your quantized filter as a mat-file, follow these steps:

  1. select export from the file menu.

  2. select mat-file under export to.

  3. assign a variable name for the filter.

  4. click ok to export the filter and close the dialog box. click apply to export the filter without closing the export dialog box. clicking apply lets you export your quantized filter to more than one name without leaving the export dialog box.

    the export filter coefficients to mat-file dialog box appears. this dialog box is the standard microsoft windows save file dialog box.

  5. choose or enter a folder and filename for the text file, and click ok.

    filter designer exports your quantized filter as a mat-file with the specified name.

generate matlab code

you can generate matlab code using the file > generate matlab code menu. this menu has these options:

  • filter design function (with system objects)

    this option generates a system object. the option is disabled when the current filter is not supported by system objects.

  • data filtering function (with system objects)

    this option generates matlab code that filters input data with the current filter design. the matlab code is ready to be converted to c/c code using the codegen command. this option is disabled when the current filter is not supported by system objects.

import xilinx coefficient (.coe) files

import xilinx .coe files into filter designer

you can import xilinx coefficients (.coe) files into filter designer to create quantized filters directly using the imported filter coefficients.

to use the import file feature:

  1. select file > import filter from xilinx coefficient (.coe) file in filter designer.

  2. in the import filter from xilinx coefficient (.coe) file dialog box, find and select the .coe file to import.

  3. click open to dismiss the dialog box and start the import process.

    filter designer imports the coefficient file and creates a quantized, single-section, direct-form fir filter.

transform filters using filter designer

filter transformation capabilities of filter designer

the toolbox provides functions for transforming filters between various forms. when you use filter designer with the toolbox installed, a side bar button and a menu bar option enable you to use the transform filter panel to transform filters as well as using the command line functions.

from the selection on the filter designer menu bar — transformations — you can transform lowpass fir and iir filters to a variety of passband shapes.

you can convert your fir filters from:

  • lowpass to lowpass.

  • lowpass to highpass.

for iir filters, you can convert from:

  • lowpass to lowpass.

  • lowpass to highpass.

  • lowpass to bandpass.

  • lowpass to bandstop.

when you click the transform filter button, , on the side bar, the transform filter panel opens in filter designer, as shown here.

your options for original filter type refer to the type of your current filter to transform. if you select lowpass, you can transform your lowpass filter to another lowpass filter or to a highpass filter, or to numerous other filter formats, real and complex.

note

when your original filter is an fir filter, both the fir and iir transformed filter type options appear on the transformed filter type list. both options remain active because you can apply the iir transforms to an fir filter. if your source is as iir filter, only the iir transformed filter options show on the list.

original filter type

select the magnitude response of the filter you are transforming from the list. your selection changes the types of filters you can transform to. for example:

  • when you select lowpass with an iir filter, your transformed filter type can be

    • lowpass

    • highpass

    • bandpass

    • bandstop

    • multiband

    • bandpass (complex)

    • bandstop (complex)

    • multiband (complex)

  • when you select lowpass with an fir filter, your transformed filter type can be

    • lowpass

    • lowpass (fir)

    • highpass

    • highpass (fir) narrowband

    • highpass (fir) wideband

    • bandpass

    • bandstop

    • multiband

    • bandpass (complex)

    • bandstop (complex)

    • multiband (complex)

in the following table you see each available original filter type and all the types of filter to which you can transform your original.

original filter

available transformed filter types

lowpass fir

  • lowpass

  • lowpass (fir)

  • highpass

  • highpass (fir) narrowband

  • highpass (fir) wideband

  • bandpass

  • bandstop

  • multiband

  • bandpass (complex)

  • bandstop (complex)

  • multiband (complex)

lowpass iir

  • lowpass

  • highpass

  • bandpass

  • bandstop

  • multiband

  • bandpass (complex)

  • bandstop (complex)

  • multiband (complex)

highpass fir

  • lowpass

  • lowpass (fir) narrowband

  • lowpass (fir) wideband

  • highpass (fir)

  • highpass

  • bandpass

  • bandstop

  • multiband

  • bandpass (complex)

  • bandstop (complex)

  • multiband (complex)

highpass iir

  • lowpass

  • highpass

  • bandpass

  • bandstop

  • multiband

  • bandpass (complex)

  • bandstop (complex)

  • multiband (complex)

bandpass fir

  • bandpass

  • bandpass (fir)

bandpass iir

bandpass

bandstop fir

  • bandstop

  • bandstop (fir)

bandstop iir

bandstop

note also that the transform options change depending on whether your original filter is fir or iir. starting from an fir filter, you can transform to iir or fir forms. with an iir original filter, you are limited to iir target filters.

after selecting your response type, use frequency point to transform to specify the magnitude response point in your original filter to transfer to your target filter. your target filter inherits the performance features of your original filter, such as passband ripple, while changing to the new response form.

for more information about transforming filters, refer to and .

frequency point to transform

the frequency point you enter in this field identifies a magnitude response value (in db) on the magnitude response curve.

when you enter frequency values in the specify desired frequency location option, the frequency transformation tries to set the magnitude response of the transformed filter to the value identified by the frequency point you enter in this field.

while you can enter any location, generally you should specify a filter passband or stopband edge, or a value in the passband or stopband.

the frequency point to transform sets the magnitude response at the values you enter in specify desired frequency location. specify a value that lies at either the edge of the stopband or the edge of the passband.

if, for example, you are creating a bandpass filter from a highpass filter, the transformation algorithm sets the magnitude response of the transformed filter at the specify desired frequency location to be the same as the response at the frequency point to transform value. thus you get a bandpass filter whose response at the low and high frequency locations is the same. notice that the passband between them is undefined. in the next two figures you see the original highpass filter and the transformed bandpass filter.

for more information about transforming filters, refer to .

transformed filter type

select the magnitude response for the target filter from the list. the complete list of transformed filter types is:

  • lowpass

  • lowpass (fir)

  • highpass

  • highpass (fir) narrowband

  • highpass (fir) wideband

  • bandpass

  • bandstop

  • multiband

  • bandpass (complex)

  • bandstop (complex)

  • multiband (complex)

not all types of transformed filters are available for all filter types on the original filter types list. you can transform bandpass filters only to bandpass filters. or bandstop filters to bandstop filters. or iir filters to iir filters.

for more information about transforming filters, refer to and .

specify desired frequency location

the frequency point you enter in frequency point to transform matched a magnitude response value. at each frequency you enter here, the transformation tries to make the magnitude response the same as the response identified by your frequency point to transform value.

while you can enter any location, generally you should specify a filter passband or stopband edge, or a value in the passband or stopband.

for more information about transforming filters, refer to .

transform filters.  to transform the magnitude response of your filter, use the transform filter option on the side bar.

  1. design or import your filter into filter designer.

  2. click transform filter, , on the side bar.

    filter designer opens the transform filter panel in filter designer.

  3. from the original filter type list, select the response form of the filter you are transforming.

    when you select the type, whether is lowpass, highpass, bandpass, or bandstop, filter designer recognizes whether your filter form is fir or iir. using both your filter type selection and the filter form, filter designer adjusts the entries on the transformed filter type list to show only those that apply to your original filter.

  4. enter the frequency point to transform value in frequency point to transform. notice that the value you enter must be in khz; for example, enter 0.1 for 100 hz or 1.5 for 1500 hz.

  5. from the transformed filter type list, select the type of filter you want to transform to.

    your filter type selection changes the options here.

    • when you pick a lowpass or highpass filter type, you enter one value in specify desired frequency location.

    • when you pick a bandpass or bandstop filter type, you enter two values — one in specify desired low frequency location and one in specify desired high frequency location. your values define the edges of the passband or stopband.

    • when you pick a multiband filter type, you enter values as elements in a vector in specify a vector of desired frequency locations — one element for each desired location. your values define the edges of the passbands and stopbands.

      after you click transform filter, filter designer transforms your filter, displays the magnitude response of your new filter, and updates the current filter information to show you that your filter has been transformed. in the filter information, the source is transformed.

      for example, the figure shown here includes the magnitude response curves for two filters. the original filter is a lowpass filter with rolloff between 0.2 and 0.25. the transformed filter is a lowpass filter with rolloff region between 0.8 and 0.85.

    • to demonstrate the effects of selecting narrowband highpass or wideband highpass, the next figure presents the magnitude response curves for a source lowpass filter after it is transformed to both narrow- and wideband highpass filters. for comparison, the response of the original filter appears as well.



      for the narrowband case, the transformation algorithm essentially reverses the magnitude response, like reflecting the curve around the y-axis, then translating the curve to the right until the origin lies at 1 on the x-axis. after reflecting and translating, the passband at high frequencies is the reverse of the passband of the original filter at low frequencies with the same rolloff and ripple characteristics.

design multirate filters in filter designer

introduction

not only can you design multirate filters from the matlab command prompt, filter designer provides the same design capability in a graphical user interface tool. by starting filter designer and switching to the multirate filter design mode you have access to all of the multirate design capabilities in the toolbox — decimators, interpolators, and fractional rate changing filters, among others.

switch filter designer to multirate filter design mode

the multirate filter design mode in filter designer lets you specify and design a wide range of multirate filters, including decimators and interpolators.

with filter designer open, click create a multirate filter, , on the side bar. you see filter designer switch to the design mode showing the multirate filter design options. shown in the following figure is the default multirate design configuration that designs an interpolating filter with an interpolation factor of 2. the design uses the current fir filter in filter designer.

when the current filter in filter designer is not an fir filter, the multirate filter design panel removes the use current fir filter option and selects the use a default nyquist fir filter option instead as the default setting.

controls on the multirate design panel

you see the options that allow you to design a variety of multirate filters. the type option is your starting point. from this list you select the multirate filter to design. based on your selection, other options change to provide the controls you need to specify your filter.

notice the separate sections of the design panel. on the left is the filter type area where you choose the type of multirate filter to design and set the filter performance specifications.

in the center section filter designer provides choices that let you pick the filter design method to use.

the rightmost section offers options that control filter configuration when you select cascaded-integrator comb (cic) as the design method in the center section. both the decimator type and interpolator type filters let you use the cascaded-integrator comb (cic) option to design multirate filters.

here are all the options available when you switch to multirate filter design mode. each option listed includes a brief description of what the option does when you use it.

select and configure your filter

option

description

type

specifies the type of multirate filter to design. choose from decimator, interpolator, or fractional-rate convertor.

  • when you choose decimator, set decimation factor to specify the decimation to apply.

  • when you choose interpolator, set interpolation factor to specify the interpolation amount applied.

  • when you choose fractional-rate convertor, set both interpolation factor and decimation factor. filter designer uses both to determine the fractional rate change by dividing interpolation factor by decimation factor to determine the fractional rate change in the signal. you should select values for interpolation and decimation that are relatively prime. when your interpolation factor and decimation factor are not relatively prime, filter designer reduces the interpolation/decimation fractional rate to the lowest common denominator and issues a message in the status bar in filter designer. for example, if the interpolation factor is 6 and the decimation factor is 3, filter designer reduces 6/3 to 2/1 when you design the rate changer. but if the interpolation factor is 8 and the decimation factor is 3, filter designer designs the filter without change.

interpolation factor

use the up-down control arrows to specify the amount of interpolation to apply to the signal. factors range upwards from 2.

decimation factor

use the up-down control arrows to specify the amount of decimation to apply to the signal. factors range upwards from 2.

sampling frequency

no settings here. just units and fs below.

units

specify whether fs is specified in hz, khz, mhz, ghz, or normalized (0 to 1) units.

fs

set the full scale sampling frequency in the frequency units you specified in units. when you select normalized for units, you do not enter a value for fs.

design your filter

option

description

use current fir filter

directs filter designer to use the current fir filter to design the multirate filter. if the current filter is an iir form, you cannot select this option. you cannot design multirate filters with iir structures.

use a default nyquist fir filter

tells filter designer to use the default nyquist design method when the current filter in filter designer is not an fir filter.

cascaded integrator-comb (cic)

design cic filters using the options provided in the right-hand area of the multirate design panel.

hold interpolator (zero-order)

when you design an interpolator, you can specify how the filter sets interpolated values between signal values. when you select this option, the interpolator applies the most recent signal value for each interpolated value until it processes the next signal value. this is similar to sample-and-hold techniques. compare to the linear interpolator option.

linear interpolator (first-order)

when you design an interpolator, you can specify how the filter sets interpolated values between signal values. when you select this option, the interpolator applies linear interpolation between signal value to set the interpolated value until it processes the next signal value. compare to the linear interpolator option.

to see the difference between hold interpolation and linear interpolation, the following figure presents a sine wave signal s1 in three forms:

  • the top subplot in the figure presents signal s1 without interpolation.

  • the middle subplot shows signal s1 interpolated by a linear interpolator with an interpolation factor of 5.

  • the bottom subplot shows signal s1 interpolated by a hold interpolator with an interpolation factor of 5.

you see in the bottom figure the sample and hold nature of hold interpolation, and the first-order linear interpolation applied by the linear interpolator.

options for designing cic filters

description

differential delay

sets the differential delay for the cic filter. usually a value of one or two is appropriate.

number of sections

specifies the number of sections in a cic decimator. the default number of sections is 2 and the range is any positive integer.

design a fractional rate convertor.  to introduce the process you use to design a multirate filter in filter designer, this example uses the options to design a fractional rate convertor which uses 7/3 as the fractional rate. begin the design by creating a default lowpass fir filter in filter designer. you do not have to begin with this fir filter, but the default filter works fine.

  1. launch filter designer.

  2. select the settings for a minimum-order lowpass fir filter, using the equiripple design method.

  3. when filter designer displays the magnitude response for the filter, click in the side bar. filter designer switches to multirate filter design mode, showing the multirate design panel.

  4. to design a fractional rate filter, select fractional-rate convertor from the type list. the interpolation factor and decimation factor options become available.

  5. in interpolation factor, use the up arrow to set the interpolation factor to 7.

  6. using the up arrow in decimation factor, set 3 as the decimation factor.

  7. select use a default nyquist fir filter. you could design the rate convertor with the current fir filter as well.

  8. enter 24000 to set fs.

  9. click create multirate filter.

    after designing the filter, filter designer returns with the specifications for your new filter displayed in current filter information, and shows the magnitude response of the filter.

you can test the filter by exporting it to your workspace and using it to filter a signal. for information about exporting filters, refer to import and export quantized filters.

design a cic decimator for 8 bit input/output data.  another kind of filter you can design in filter designer is cascaded-integrator comb (cic) filters. filter designer provides the options needed to configure your cic to meet your needs.

  1. launch filter designer and design the default fir lowpass filter. designing a filter at this time is an optional step.

  2. switch filter designer to multirate design mode by clicking on the side bar.

  3. for type, select decimator, and set decimation factor to 3.

  4. to design the decimator using a cic implementation, select cascaded-integrator comb (cic). this enables the cic-related options on the right of the panel.

  5. set differential delay to 2. generally, 1 or 2 are good values to use.

  6. enter 2 for the number of sections.

  7. click create multirate filter.

    filter designer designs the filter, shows the magnitude response in the analysis area, and updates the current filter information to show that you designed a tenth-order cascaded-integrator comb decimator with two sections. notice the source is multirate design, indicating you used the multirate design mode in filter designer to make the filter. filter designer should look like this now.

designing other multirate filters follows the same pattern.

to design other multirate filters, do one of the following depending on the filter to design:

  • to design an interpolator, select one of these options.

    • use a default nyquist fir filter

    • cascaded-integrator comb (cic)

    • hold interpolator (zero-order)

    • linear interpolator (first-order)

  • to design a decimator, select from these options.

    • use a default nyquist fir filter

    • cascaded-integrator comb (cic)

  • to design a fractional-rate convertor, select use a default nyquist fir filter.

quantize multirate filters

after you design a multirate filter in filter designer, the quantization features enable you to convert your floating-point multirate filter to fixed-point arithmetic.

note

cic filters are always fixed-point.

with your multirate filter as the current filter in filter designer, you can quantize your filter and use the quantization options to specify the fixed-point arithmetic the filter uses.

quantize and configure multirate filters.  follow these steps to convert your multirate filter to fixed-point arithmetic and set the fixed-point options.

  1. design or import your multirate filter and make sure it is the current filter in filter designer.

  2. click the set quantization parameters button on the side bar.

  3. from the filter arithmetic list on the filter arithmetic pane, select fixed-point. if your filter is a cic filter, the fixed-point option is enabled by default and you do not set this option.

  4. in the quantization panes, set the options for your filter. set options for coefficients, input/output, and filter internals.

  5. click apply.

when you current filter is a cic filter, the options on the input/output and filter internals panes change to provide specific features for cic filters.

input/output.  the options that specify how your cic filter uses input and output values are listed in the table below.

option name

description

input word length

sets the word length used to represent the input to a filter.

input fraction length

sets the fraction length used to interpret input values to filter.

input range ( /-)

lets you set the range the inputs represent. you use this instead of the input fraction length option to set the precision. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

output word length

sets the word length used to represent the output from a filter.

avoid overflow

directs the filter to set the fraction length for the input to prevent the output values from exceeding the available range as defined by the word length. clearing this option lets you set output fraction length.

output fraction length

sets the fraction length used to represent output values from a filter.

output range ( /-)

lets you set the range the outputs represent. you use this instead of the output fraction length option to set the precision. when you enter a value x, the resulting range is -x to x. range must be a positive integer.

the available options change when you change the filter precision setting. moving from full to specify all adds increasing control by enabling more input and output word options.

filter internals.  with a cic filter as your current filter, the filter precision option on the filter internals pane includes modes for controlling the filter word and fraction lengths.

there are four usage modes for this (the same mode you select for the filterinternals property in cic filters at the matlab prompt).

  • full — all word and fraction lengths set to bmax 1, called baccum. this is the default.

  • minimum section word lengths — set the section word lengths to minimum values that meet roundoff noise and output requirements.

  • specify word lengths — enables the section word length option for you to enter word lengths for each section. enter either a scalar to use the same value for every section, or a vector of values, one for each section.

  • specify all — enables the section fraction length option in addition to section word length. now you can provide both the word and fraction lengths for each section, again using either a scalar or a vector of values.

export individual phase coefficients of a polyphase filter to the workspace

after designing a polyphase filter in the filter designer app, you can obtain the individual phase coefficients of the filter by:

  1. exporting the filter to an object in the matlab workspace.

  2. using the polyphase method to create a matrix of the filter's coefficients.

export the polyphase filter to an object.  to export a polyphase filter to an object in the matlab workspace, complete the following steps.

  1. in filter designer, open the file menu and select export.... this opens the dialog box for exporting the filter coefficients.

  2. in the export dialog box, for export to, select workspace.

  3. for export as, select object.

  4. (optional) for variable names, enter the name of the multirate filter object that will be created in the matlab workspace.

  5. click the export button. the multirate filter object, hm in this example, appears in the matlab workspace.

create a matrix of coefficients using the polyphase method.  to create a matrix of the filter's coefficients, enter p=polyphase(hm) at the command line. the method creates a matrix, p, of filter coefficients from the filter object, hm. each row of p consists of the coefficients of an individual phase subfilter. the first row contains to the coefficients of the first phase subfilter, the second row contains those of the second phase subfilter, and so on.

realize filters as simulink subsystem blocks

introduction

after you design or import a filter in filter designer, the realize model feature lets you create a simulink subsystem block that implements your filter. the generated filter subsystem block uses either digital filter blocks from the dsp system toolbox library, or the delay, gain, and sum blocks in simulink. if you do not have a fixed-point designer™ license, filter designer still realizes your model using blocks in fixed-point mode from simulink, but you cannot run any model that includes your filter subsystem block in simulink.

about the realize model panel in filter designer

to access to the realize model panel and the options for realizing your quantized filter as a simulink subsystem block, switch filter designer to realize model mode by clicking on the sidebar.

the following panel shows the options for configuring how filter designer implements your filter as a simulink block.

for information on these parameters, see the descriptions on the block reference page.

realize a filter using filter designer.  after your quantized filter in filter designer is performing the way you want, with your desired phase and magnitude response, and with the right coefficients and form, follow these steps to realize your filter as a subsystem that you can use in a simulink model.

  1. click realize model on the sidebar to change filter designer to realize model mode.

  2. from the destination list under model, select either:

    • current model — to add the realized filter subsystem to your current model

    • new model — to open a new simulink model window and add your filter subsystem to the new window

  3. provide a name for your new filter subsystem in the name field.

  4. decide whether to overwrite an existing block with this new one, and select or clear the overwrite generated ‘filter’ block check box.

  5. select the build model using basic elements check box to implement your filter as a subsystem block that consists of sum, gain, and delay blocks.

  6. select or clear the optimizations to apply.

    • optimize for zero gains — removes zero gain blocks from the model realization

    • optimize for unity gains — replaces unity gain blocks with direct connections to adjacent blocks

    • optimize for negative gains — replaces negative gain blocks by a change of sign at the nearest sum block

    • optimize delay chains — replaces cascaded delay blocks with a single delay block that produces the equivalent gain

    • optimize for unity scale values — removes all scale value multiplications by 1 from the filter structure

  7. click realize model to realize your quantized filter as a subsystem block according to the settings you selected.

if you double-click the filter block subsystem created by filter designer, you see the filter implementation in simulink model form. depending on the options you chose when you realized your filter, and the filter you started with, you might see one or more sections, or different architectures based on the form of your quantized filter. from this point on, the subsystem filter block acts like any other block that you use in simulink models.

related topics

    网站地图