Signal Processing Toolbox

Frequency-Domain Based Modeling

The invfreqs and invfreqz functions implement the inverse operations of freqs and freqz; they find an analog or digital transfer function of a specified order that matches a given complex frequency response. Though the following examples demonstrate invfreqz, the discussion also applies to invfreqs.

To recover the original filter coefficients from the frequency response of a simple digital filter

The vector of frequencies w has the units in rad/sample, and the frequencies need not be equally spaced. invfreqz finds a filter of any order to fit the frequency data; a third-order example is

Both invfreqs and invfreqz design filters with real coefficients; for a data point at positive frequency f, the functions fit the frequency response at both f and -f.

By default invfreqz uses an equation error method to identify the best model from the data. This finds b and a in

by creating a system of linear equations and solving them with MATLAB's \ operator. Here A(w(k)) and B(w(k)) are the Fourier transforms of the polynomials a and b respectively at the frequency w(k), and n is the number of frequency points (the length of h and w). wt(k) weights the error relative to the error at different frequencies. The syntax

includes a weighting vector. In this mode, the filter resulting from invfreqz is not guaranteed to be stable.

invfreqz provides a superior ("output-error") algorithm that solves the direct problem of minimizing the weighted sum of the squared error between the actual frequency response points and the desired response

To use this algorithm, specify a parameter for the iteration count after the weight vector parameter

The resulting filter is always stable.

Graphically compare the results of the first and second algorithms to the original Butterworth filter.

To verify the superiority of the fit numerically, type