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

ultrwin

Ultraspherical window


Description

Return the coefficients of an ultraspherical window.

Usage

ultrwin(n, mu, pvalue, ptype = c("xmu", "beta", "att", "latt"))

Arguments

n

Window length, specified as a positive integer (controls main lobe width)

mu

parameter that controls the side-lobe roll-off ratio of the Fourier transform of the window.

pvalue

parameter value used for controlling the transform’s main-lobe width/side-lobe-ratio.

ptype

type of parameter passed in pvalue. Can be one of:

"xmu" (default)

controls the ripple ratio by setting the (un-normalized) window’s Fourier transform according to its canonical definition:

           (MU)
    W(k) = C   [ xmu cos(pi k/M) ],  k = 0, 1, ..., M-1,
           M-1

where C is the Ultraspherical (a.k.a. Gegenbauer) polynomial, which can be defined using the recurrence relationship:

     (l)    1                  (l)                    (l)
    C (x) = - [ 2x(m + l - 1) C   (x) - (m + 2l - 2) C   (x) ]
     m      m                  m-1                    m-2
                                (l)        (l)
     for m an integer > 1, and C (x) = 1, C (x) = 2lx.
                                0          1

Note that when not giving xmu, stability issues may occur with mu <= -1.5.

"beta"

sets the main lobe width to beta times that of a rectangular window.

"att"

sets the ripple ratio at the first

"latt"

sets the ripple ratio at the last side-lobe

Details

Windows can be characterized as fixed or adjustable. Fixed windows have only one independent parameter, namely, the window length which controls the main-lobe width. Adjustable windows have one or more additional parameters that can control other window characteristics, such as the relative side-lobe amplitude (e.g., kaiser. chebwin). The ultraspherical window has an additional parameter that can be used to set the rate at which side-lobes decrease (or increase) in amplitude as a function of frequency. This can be useful, for instance, if a very sharp attenuation immediately next to the transition band is desired.

Ref [1] details methods to set the parameters that can be used for designing specific spectral characteristics of the window.

Value

Ultraspherical window, returned as a vector.

Note

The Dolph-Chebyshev and Saramaki windows are special cases of the Ultraspherical window, with mu set to 0 and 1 respectively.

Author(s)

Rob Sykes, robs@users.sourceforge.net.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

References

[1] Bergen, S.W.A., Antoniou, A. (2004). Design of Ultraspherical Window Functions with Prescribed Spectral Characteristics. EURASIP J. Appl. Sign. Proc. 13, 2053-2065
[2] https://en.wikipedia.org/wiki/Window_function#Ultraspherical_window

Examples

## Window with sharp attenuation next to transition band
w <- ultrwin(120, -1, 40, "l")
fz <- freqz(w)
op <- par(mfrow = c(2, 1))
plot (seq(0, length(w) - 1), w, type = "l", xlab = "", ylab ="")
plot (fz$w / pi, 20 * log10(abs(fz$h) / abs(fz$h[1])), type = "l",
      xlab = "", ylab = "")
par(op)

## Varying beta with fixed mu
x <- y <- NULL
for (beta in 2:5) {
  w <- ultrwin(80, -.5, beta, "beta"); fz  <- freqz(w)
  x <- cbind(x, fz$w / pi)
  y <- cbind(y, 20 * log10(abs(fz$h) / abs(fz$h[1])))
}
matplot(x, y, type = "l", lty = 1, xlab = "", ylab = "", ylim = c(-150,0),
  main = expression(paste("Varying ", beta, " with ", mu, " = 0.5")))
legend("topright", legend = 2:5, title = "Beta", lty = 1, col = 1:4)

## Varying n with fixed mu and beta
x <- y <- NULL
for (n in 2:10) {
  w <- ultrwin(n * 20, 1, 3, "beta"); fz  <- freqz(w, 1, 2^11)
  x <- cbind(x, fz$w / pi)
  y <- cbind(y, 20 * log10(abs(fz$h) / abs(fz$h[1])))
}
matplot(x, y, type = "l", lty = 1, xlab = "", ylab = "",
  xlim = c(0, 0.25), ylim = c(-100, 0), col = 1:9,
  main = expression(paste("Varying n with ", mu, " = 1 and ", beta, " = 3")))
legend("topright", legend = 20*(2:10), title = "n", lty = 1, col = 1:9)

## Varying mu with fixed m and att
x <- y <- NULL
for (j in 0:4) {
  w <- ultrwin(80, j * .6 - 1.2, 50, "att"); fz  <- freqz(w)
  x <- cbind(x, fz$w / pi)
  y <- cbind(y, 20 * log10(abs(fz$h) / abs(fz$h[1])))
}
matplot(x, y, type = "l", lty = 1, xlab = "", ylab = "",
  xlim = c(0, 1), ylim = c(-100, 0), col = 1:5,
  main = expression(paste("Varying ", mu, " with n = 80 and att = 50")))
legend("topright", legend = (0:4) * .6 - 1.2, title = expression(mu),
  lty = 1, col = 1:5)

## Varying mu with fixed m and latt
x <- y <- NULL
for (j in rev(0:4)) {
  w <- ultrwin(80, j * .75 - 1.5, 50, "latt"); fz  <- freqz(w)
  x <- cbind(x, fz$w / pi)
  y <- cbind(y, 20 * log10(abs(fz$h) / abs(fz$h[1])))
}
matplot(x, y, type = "l", lty = 1, xlab = "", ylab = "",
  xlim = c(0, 1), ylim = c(-100, 0), col = 1:5,
  main = expression(paste("Varying ", mu, " with n = 80 and latt = 50")))
legend("topright", legend = (0:4) * .6 - 1.2, title = expression(mu),
  lty = 1, col = 1:5)

## Compare ultraspherical, Dolph-Chebyshev and Kaiser windows
x <- y <- NULL
for (i in 1:3) {
  w <- switch(i, ultrwin(153, 0.5, 2.6, "beta"),
                 ultrwin(165, 0, 2.73, "beta"),
                 kaiser(159, 7.91))
  fz <- freqz(w, fs = 1.2 * pi)
  x <- cbind(x, fz$w)
  y <- cbind(y, 20 * log10(abs(fz$h) / abs(fz$h[1])))
}
matplot(x, y, type = "l", lty = 1, xlab = "", ylab = "", col = 1:3,
  xlim = c(0, 1), ylim = c(-130, 0))
legend("topright", lty = 1, col = 1:3,
  legend = c("Ultraspherical", "Dolph-Chebyshev", "Kaiser"))

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.