freqz: Frequency response of digital filter

View source: R/freqz.R

freqzR Documentation

Frequency response of digital filter

Description

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

Usage

freqz(filt, ...)

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

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

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

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

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

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

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

## S3 method for class '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.

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.

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.

Note

When results of freqz are printed, freqz_plot will be called to display frequency plots of magnitude and phase. As with lattice plots, automatic printing does not work inside loops and function calls, so explicit calls to print or plot are needed there.

Author(s)

John W. Eaton, Paul Kienzle, pkienzle@users.sf.net.
Port to R by Tom Short,
adapted by Geert van Boxtel, gjmvanboxtel@gmail.com

Examples

b <- c(1, 0, -1)
a <- c(1, 0, 0, 0, 0.25)
freqz(b, a)

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


gjmvanboxtel/gsignal documentation built on Nov. 22, 2023, 8:19 p.m.