Learn R Programming

gsignal (version 0.3-1)

freqz: Frequency response of digital filter

Description

Compute the z-plane frequency response of an ARMA model or rational IIR filter.

Usage

freqz(filt, ...)

# S3 method for default freqz( filt, a = 1, n = 512, whole = ifelse((is.numeric(filt) && is.numeric(a)), FALSE, TRUE), fs = 2 * pi, ... )

# S3 method for Arma freqz( filt, n = 512, whole = ifelse((is.numeric(filt$b) && is.numeric(filt$a)), FALSE, TRUE), fs = 2 * pi, ... )

# S3 method for Ma freqz( filt, n = 512, whole = ifelse(is.numeric(filt), FALSE, TRUE), fs = 2 * pi, ... )

# S3 method for Sos freqz(filt, n = 512, whole = FALSE, fs = 2 * pi, ...)

# S3 method for Zpg freqz(filt, n = 512, whole = FALSE, fs = 2 * pi, ...)

# S3 method for freqz print(x, ...)

# S3 method for freqz summary(object, ...)

# S3 method for summary.freqz print(x, ...)

freqz_plot(w, h, ...)

Arguments

filt

for the default case, the moving-average coefficients of an ARMA model or filter. Generically, filt specifies an arbitrary model or filter operation.

...

for methods of freqz, arguments are passed to the default method. For freqz_plot, additional arguments are passed through to plot.

a

the autoregressive (recursive) coefficients of an ARMA filter.

n

number of points at which to evaluate the frequency response. If n is a vector with a length greater than 1, then evaluate the frequency response at these points. For fastest computation, n should factor into a small number of small primes. Default: 512.

whole

FALSE (the default) to evaluate around the upper half of the unit circle or TRUE to evaluate around the entire unit circle.

fs

sampling frequency in Hz. If not specified (default = 2 * pi), the frequencies are in radians.

x

object to be printed or plotted.

object

object of class "freqz" for summary

w

vector of frequencies

h

complex frequency response \(H(e^{j\omega})\), specified as a vector.

Value

For freqz, a list of class 'freqz' with items:

h

complex array of frequency responses at frequencies f.

w

array of frequencies.

u

units of (angular) frequency; either rad/s or Hz.

Details

The frequency response of a digital filter can be interpreted as the transfer function evaluated at \(z = e^{j\omega}\).

The 'Matlab' and 'Octave' versions of freqz produce magnitude and phase plots. The freqz version in the 'signal' package produces separate plots of magnitude in the pass band (max - 3 dB to max) and stop (total) bands, as well as a phase plot. The current version produces slightly different plots. The magnitude plots are separate for stop and pass bands, but the pass band plot has an absolute lower limit of -3 dB instead of max - 3 dB. In addition a summary method was added that prints out the most important information about the frequency response of the filter.

Examples

Run this code
# NOT RUN {
b <- c(1, 0, -1)
a <- c(1, 0, 0, 0, 0.25)
freqz(b, a)

hw <- freqz(b, a)
summary(hw)

# }

Run the code above in your browser using DataLab