FilterFrequencyResponse - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


SignalProcessing

  

FilterFrequencyResponse

  

determine the response of an FIR or IIR digital filter from taps

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

FilterFrequencyResponse( A, options )

FilterFrequencyResponse( A, B, options )

Parameters

A

-

1-D rtable or list of numeric values for the coefficients of the numerator of the transfer function.

B

-

(optional) 1-D rtable or list of numeric values for the coefficients of the denominator of the transfer function. The default is NULL.

Options

• 

fftnormalization: (optional) One of none, symmetric, or full, indicates the normalization to be applied when using the Fast Fourier Transform (FFT). The default is symmetric.

• 

magnitudeplotoptions: (optional) Additional plot options to be passed when creating the plot of the magnitudes. The default is [].

• 

phaseplotoptions: (optional) Additional plot options to be passed when creating the plot of the phases. The default is [].

• 

phaseunit: (optional) Specifies the unit of angle for the phases. The default is Unit(degrees). Either of the forms algebraic or Unit(algebraic) is accepted, and the unit must be convertible to a valid unit of angle.

• 

samplerate: (optional) Positive numeric value for the sampling rate. The default is NULL.

• 

size: (optional) Positive integer larger than 1, which specifies the computed size of the response, magnitudes, and phases Vectors. The default is the smallest power of 2 that is greater than or equal to all of 512, numelems(A), and (if passed) numelems(B).

• 

output: (optional) The type of output. The supported options are:

– 

frequencies: Returns a Vector, of float[8] datatype and length size, containing the frequencies.

– 

magnitudes: Returns a Vector of float[8] datatype and length size containing the magnitudes.

– 

phases: Returns a Vector of float[8] datatype and length size containing the phases.

– 

response: Returns a Vector of complex[8] datatype and length size containing the response. This is the default.

– 

magnitudeplot: Returns a plot of the magnitudes versus the frequencies.

– 

phaseplot: Returns a plot of the phases versus the frequencies.

– 

record: Returns a record with the previous options.

– 

list of any of the above options: Returns an expression sequence with the corresponding outputs, in the same order.

Description

• 

The FilterFrequencyResponse command computes the frequency response of the transfer function indicated by the taps stored in one or two rtables/lists of 1-D data.

• 

The A container stores the coefficients of the numerator of the transfer function and, if passed, B stores the coefficients of the denominator. Each of the containers must contain one or more elements.

• 

For the IIR (Infinite Impulse Response) case, the impulse transfer function in terms of the taps is given by the following:

Hz=k=1mAkzk1k=1nBkzk1

  

where m=numelemsA and n=numelemsB. For the FIR (Finite Impulse Response) case:

Hz=k=1mAkzk1

• 

Internally, the taps containers are padded with sufficiently many zeros, if necessary, so that the response will be of length size.

• 

When only numerator taps are passed (FIR case), the response is the Fast Fourier Transform (FFT) of the padded taps container. When denominator taps are also passed (IIR case), the response is the element-wise quotient of the FFTs of the respective padded taps containers. When the taps are all real-valued, the padded length will be 2*size, and then the redundant (due to symmetry) second half of any FFT will be discarded. On the other hand, when one or more taps is complex, the padded length will be just size, and no terms will be discarded.

• 

The magnitudes are first computed as the element-wise absolute values of the response. Then, they are converted to decibels via the transformation ρ10log10ρ for the complex case, and ρ20log10ρ for the real-case (the extra factor of 2 is due to the symmetry and discarding of the second half of the FFTs).

• 

The phases are first computed as the element-wise angles/arguments of the response. Then, they are "unwrapped" to eliminate big jumps in the phases, and finally, if phaseunit=degrees, converted to angles (a common convention).

• 

When samplerate=NULL, the frequencies Vector F is of size n=size and "normalized", with components defined by the following:

Fk=k1n

  

When r=samplerate is not NULL, on the other hand:

Fk=k1rn

• 

The samplerate option can include a unit, which will be included in the plots. Either of the forms algebraic or Unit(algebraic) is accepted, but the unit must be convertible to a valid unit of frequency.

• 

Maple will attempt to coerce the provided taps to Vectors of complex[8] datatype, and an error will be thrown if this is not possible. For this reason, it is most efficient for the passed taps to use this datatype.

• 

Input rtables cannot have an indexing function, and must use rectangular storage.

• 

The FilterFrequencyResponse command is not thread safe.

Examples

withSignalProcessing:

Simple Examples

FilterFrequencyResponse5,3,7,1,10,size=8

5.+0.I1.890198075784273.68139417593046I−1.957106781186551.39644660940673I−0.505419324478097+2.05114364039828I2.+I0.5305455903251810.473982625448804I−0.542893218813452+2.10355339059327I3.08467565836865+3.79347955822245I

(1)

F,R,M,PFilterFrequencyResponse1,23I,4,5,67I,samplerate=2.5,size=4,output=frequencies,response,magnitudes,phases

F,R,M,P0.0.6250000000000001.250000000000001.87500000000000,0.576470588235294+0.0941176470588235I0.6000000000000000.800000000000000I0.3600000000000000.480000000000000I0.0666666666666667+0.133333333333333I,−2.335104639076680.−2.21848749616356−8.26606256887672,9.27260177720030−53.1301023541560−53.130102354156063.4349488229220

(2)

Real FIR Filter

• 

First, generate some FIR taps using the GenerateFIRFilterTaps command:

TapsGenerateFIRFilterTaps48,0.25,window=Hamming,normalize=false,filtertype=lowpass

Taps−0.000766226652048602−0.0008413391496714700.001008607404047670.00127911948879349−0.00166460722830032−0.002177698278995560.002832285591326240.00364406190199566−0.00463129091647615−0.005815925810116530.007225250693016810.00889433259851163−0.0108697711579715−0.01321560393683070.01602294765573570.0194264426666097−0.0236338399613289−0.02898287244730020.03606012258515080.0459783098573302−0.0611288196507035−0.08774012691350400.1486695910602470.4496957394879000.4496957394879000.148669591060247−0.0877401269135040−0.06112881965070350.04597830985733020.0360601225851508−0.0289828724473002−0.02363383996132890.01942644266660970.0160229476557357−0.0132156039368307−0.01086977115797150.008894332598511630.00722525069301681−0.00581592581011653−0.004631290916476150.003644061901995660.00283228559132624−0.00217769827899556−0.001664607228300320.001279119488793490.00100860740404767−0.000841339149671470−0.000766226652048602

(3)
• 

Now, display plots of the magnitude and phase of the response:

num_points1024

num_points1024

(4)

RFilterFrequencyResponseTaps,size=num_points,output=record:

Rmagnitudeplot

Rphaseplot

IIR Filter

• 

Here, we will obtain taps for a lowpass digital Chebyshev Type I Filter from the GenerateChebyshev1Taps command:

cutoff_frequency_ratio0.4

cutoff_frequency_ratio0.4

(5)

filter_order5

filter_order5

(6)

ripple29

ripple29

(7)

TapsGenerateChebyshev1Tapsfilter_order,cutoff_frequency_ratio,ripple,filtertype=lowpass

Taps0.01452562229512240.07262811147561200.1452562229512240.1452562229512240.07262811147561200.01452562229512241.1.677643285741721.12542851668154−0.885659875792074−1.51371985423053−0.938872158956746

(8)
• 

The first half of the Taps Vector are for the numerator, and the second half are for the denominator:

A,BListTools:-SliceTaps,2

A,B0.01452562229512240.07262811147561200.1452562229512240.1452562229512240.07262811147561200.0145256222951224,1.1.677643285741721.12542851668154−0.885659875792074−1.51371985423053−0.938872158956746

(9)
• 

Now, we plot the magnitudes and phases of the response:

num_points1024

num_points1024

(10)

RFilterFrequencyResponseA,B,samplerate=5.0UnitHz,size=num_points,output=record:

Rmagnitudeplot

Rphaseplot

Complex FIR Filter

n25

n25

(11)

TapsVectorn,kk+I−1k,datatype=complex8

num_points2048

num_points2048

(12)

RFilterFrequencyResponseTaps,samplerate=2.0,size=num_points,phaseunit=radians,output=record:

Rmagnitudeplot

Rphaseplot

Compatibility

• 

The SignalProcessing[FilterFrequencyResponse] command was introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

ListTools[Slice]

SignalProcessing

SignalProcessing[FFT]

SignalProcessing[GenerateChebyshev1Taps]

SignalProcessing[GenerateFIRFilterTaps]

SignalProcessing[Magnitude]

SignalProcessing[Phase]