# ZFREQ

## Purpose:

Evaluates the frequency response of a Z-transform.

## Syntax:

ZFREQ(b, a, N, Fs, whole)

b

-

A series. The numerator (i.e. zero) coefficients in ascending powers of z-1.

a

-

A series. The denominator (i.e. pole) coefficients in ascending powers of z-1. If the first coefficient is not 1.0, the coefficients are assumed to be in difference equation form.

N

-

Optional. An integer, the number of output samples, defaults to 2048.

Fs

-

Optional. A real, the sample rate of data. If the rates of the numerator and denominator coefficients are equal, the rate defaults to the coefficient rate, else the rate defaults to 1.0.

whole

-

Optional. An integer or string, the evaluation contour. Valid inputs are:

 0: evaluate the transform only over the upper half of the unit circle (default) 1: evaluate the transform over the entire unit circle

If whole is a string, the transform is evaluated over the entire unit circle.

## Alternate Syntax:

ZFREQ(c, N, Fs, whole)

c

-

A series. The system coefficients in cascaded bi-quad form. If c contains 2 columns, the coefficients are assumed to be in direct form, where the first column is b and the second column is a.

N

-

Optional. An integer, the number of output samples, defaults to 2048.

Fs

-

Optional. A real, the sample rate of data. Defaults to the rate of the coefficients.

whole

-

Optional. An integer or string, the evaluation contour. Valid inputs are:

 0: evaluate the transform only over the upper half of the unit circle (default) 1: evaluate the transform over the entire unit circle

If whole is a string, the transform is evaluated over the entire unit circle.

## Returns:

A complex series.

## Example:

W1: mag(zfreq({1}, {1, -0.5, 0.6}))

setxlog(w1, 1);setylog(w1, 1);

gridsol;gridhv;scales(2)

W1 contains 2048 uniformly spaced samples of the magnitude of the frequency response of the Z-transform:

The frequency samples range from 0 to 0.5 Hz.

## Example:

W1: zfreq( {1}, {1, -0.5, 0.6}, 0..1/200..0.5)

Same as the previous example, except the complex response is returned and explicit frequencies (in Hertz) are specified.

## Example:

W2: zfreq( {1}, {0.5, -0.6} )

Since the leading pole coefficient is not 1.0, the coefficients are assumed to be in difference equation form, i.e. the coefficients represent the system:

The Z-transform of this difference equation is identical to the previous example, so ZFREQ yields the same result.

## Example:

W1: zfreq( {1}, {1, -0.5, 0.6}, 1024, 1.0, 1 )

Same as the first example, except the 1024 samples of the frequency response are evaluated over the entire unit circle, i.e. the frequency samples range from 0.0 to 1.0 Hz.

## Remarks:

ZFREQ uses the FFT method to evaluate the specified number of uniformly spaced samples over the unit circle of a Z-transform in direct form. If a[1] = 1, the coefficients are assumed to be in standard Z-transform form:

 z = e jω complex frequency N = number of numerator terms M = number of denominator terms

This form represents the following difference equation:

If the leading term of the denominator is not 1.0, a[1] 1, the coefficients are assumed to be in difference equation form:

or equivalently:

For zfreq(c, N, Fs, whole), the input c is assumed to be a single column of coefficients in cascaded bi-quad form. This is the output format of IIR filters designed by DADiSP/Filters and processed by the CASCADE function.

or equivalently:

where G is the system gain, bk and ak are the filter coefficients for the kth stage.

If c contains 2 columns, the coefficients are assumed to be in direct form, where the first column is b and the second column is a.

ZFREQ returns a complex series. Use MAG or PHASE to obtain the magnitude and/or phase components separately.

See IMPZ to display the impulse response of a Z-transform.

See FREQZ to automatically display the magnitude and phase responses in two separate Windows.