Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

freqz

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ω}), specified as a vector.

Details

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

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)

gsignal

Signal Processing

v0.3-1
GPL-3
Authors
Geert van Boxtel [aut, cre] (Maintainer), Tom Short [aut] (Author of 'signal' package), Paul Kienzle [aut] (Majority of the original sources), Ben Abbott [ctb], Juan Aguado [ctb], Muthiah Annamalai [ctb], Leonardo Araujo [ctb], William Asquith [ctb], David Bateman [ctb], David Billinghurst [ctb], Juan Pablo Carbajal [ctb], André Carezia [ctb], Vincent Cautaerts [ctb], Eric Chassande-Mottin [ctb], Luca Citi [ctb], Dave Cogdell [ctb], Carlo de Falco [ctb], Carne Draug [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], R.G.H Eschauzier [ctb], Andrew Fitting [ctb], Alan J. Greenberger [ctb], Mike Gross [ctb], Daniel Gunyan [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Jake Janovetz [ctb], Alexander Klein [ctb], Peter V. Lanspeary [ctb], Bill Lash [ctb], Friedrich Leissh [ctb], Laurent S. Mazet [ctb], Mike Miller [ctb], Petr Mikulik [ctb], Paolo Neis [ctb], Georgios Ouzounis [ctb], Sylvain Pelissier [ctb], Francesco Potortì [ctb], Charles Praplan [ctb], Lukas F. Reichlin [ctb], Tony Richardson [ctb], Asbjorn Sabo [ctb], Thomas Sailer [ctb], Rolf Schirmacher [ctb], Rolf Schirmacher [ctb], Ivan Selesnick [ctb], Julius O. Smith III [ctb], Peter L. Soendergaard [ctb], Quentin Spencer [ctb], Doug Stewart [ctb], P. Sudeepam [ctb], Stefan van der Walt [ctb], Andreas Weber [ctb], P. Sudeepam [ctb], Andreas Weingessel [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.