# INVFREQS

## Purpose:

Computes analog filter coefficients from a complex frequency response.

## Syntax:

INVFREQS(h, w, N, M, wf, maxiter, tol)

(b, a) = INVFREQS(h, w, N, M, wf, maxiter, tol)

 h - A series. The desired complex frequency response. w - A series. The normalized frequency samples in radians/s where 0 <= w <= π and length(w) == length(h). N - An integer. The order of the numerator polynomial. M - An integer. The order of the denominator polynomial. wf - Optional. A series, the weight at each frequency sample. Can be empty or a series with the same length as h where wf > 0. Defaults to a series of all ones (i.e. unity weighting). maxiter - Optional. An integer, the maximum number of iterations for the Gauss-Newton minimization option. Defaults to 30 if specified as empty. tol - Optional. A real, the tolerance of the gradient norm for the iteration step. Defaults to 0.01 if specified as empty.

## Alternate Syntax:

INVFREQS(h, w, "complex", N, M, wf, maxiter, tol)

(b, a) = INVFREQS(h, w, "complex", N, M, wf, maxiter, tol)

 h - A series. The desired complex frequency response. w - A series. The normalized frequency samples in radians/s where -π <= w <= π and length(w) == length(h). "complex" - A string, Specifies that complex filter coefficients will be computed. N - An integer. The order of the numerator polynomial. M - An integer. The order of the denominator polynomial. wf - Optional. A series, the weight at each frequency sample. Can be empty or a series with the same length as h where wf > 0. Defaults to a series of all ones (i.e. unity weighting). maxiter - Optional. An integer, the maximum number of iterations for the Gauss-Newton minimization option. Defaults to 30 if specified as empty. tol - Optional. A real, the tolerance of the gradient norm for the iteration step. Defaults to 0.01 if specified as empty.

## Returns:

A two column series where the values of column 1 are the numerator coefficients and the values of column 2 are the denominator coefficients.

(b, a) = INVFREQS(h, w, N, M, maxiter, tol) returns the numerator and denominator coefficients as two separate series.

If "complex" is specified, complex coefficients are returned.

## Example:

b = {1, 2, 3, 2, 3}

a = {1, 2, 3, 2, 1, 4}

(h, w) = freqs(b, a, 64);

(b1, a1) = invfreqs(h, w, 4, 5)

b1 == {1, 2, 3, 2, 3}

a1 == {1, 2, 3, 2, 1, 4}

The variables h and w contain the complex frequency response and frequency values of the system to model. Although INVFREQS computes the filter coefficients that match the original values, because the denominator contains poles in the right half plane, the system is unstable.

## Example:

(b2, a2) = invfreqs(h, w, 4, 5, {}, 20)

b2 == {0.681558,2.101515,2.669447,0.911304,-0.121828}

a2 == {1.000000,3.467584,7.405952,6.210168, 2.541314,0.000085}

By specifying an iteration value, INVFREQS computes the filter coefficients using the Gauss-Newton minimization method. The computed system is stable (all denominator poles are in the left half plane).

## Remarks:

INVFREQS computes analog filter coefficients given a complex frequency response and normalized frequency values for the following continuous system:

where s =, the complex frequency. The parameters N and M determine the order of the numerator and denominator polynomials such that N+1 and M+1 coefficients will be returned.

If maxiter is not specified, the coefficients are computed by minimizing:

If maxiter is specified as empty or an integer, the coefficients are computed using the Gauss-Newton method to minimize:

The input frequencies, ω, are specified in radians/seconds such that ω = 2πf, where f is frequency in Hertz.

If "complex" is not specified, real coefficients are computed. In this case, the normalized frequency values must range from 0 to π and the response of the filter at negative frequencies is automatically set to conj(h) to maintain proper symmetry.

If "complex" is specified, complex filter coefficients are computed and the normalized frequency samples can range from -π to π and no frequency domain symmetry is enforced.

The first coefficient of a, the denominator polynomial, is 1.0.

See INVFREQZ to compute digital filter coefficients from a complex frequency response.