# NOT RUN {
## 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"))
# }
Run the code above in your browser using DataLab