Compute the Chirp Z-transform along a spiral contour on the z-plane.
czt(x, m = NROW(x), w = exp(complex(real =0, imaginary =-2* pi/m)), a =1)
Arguments
x: input data, specified as a numeric vector or matrix. In case of a vector it represents a single signal; in case of a matrix each column is a signal.
m: transform length, specified as a positive integer scalar. Default: NROW(x).
w: ratio between spiral contour points in each step (i.e., radius increases exponentially, and angle increases linearly), specified as a complex scalar. Default: exp(0-1i * 2 * pi / m).
a: initial spiral contour point, specified as a complex scalar. Default: 1.
Returns
Chirp Z-transform, returned as a vector or matrix.
Details
The chirp Z-transform (CZT) is a generalization of the discrete Fourier transform (DFT). While the DFT samples the Z plane at uniformly-spaced points along the unit circle, the chirp Z-transform samples along spiral arcs in the Z-plane, corresponding to straight lines in the S plane. The DFT, real DFT, and zoom DFT can be calculated as special cases of the CZT[1]. For the specific case of the DFT, a = 0, m = NCOL(x), and w = 2 * pi / m[2, p. 656].
Examples
fs <-1000# sampling frequencysecs <-10# number of secondst <- seq(0, secs,1/fs)# time seriesx <- sin(100*2* pi * t)+ runif(length(t))# 100 Hz signal + noisem <-32# n of points desiredf0 <-75; f1 <-175;# desired freq rangew <- exp(-1i*2* pi *(f1 - f0)/((m -1)* fs))# freq step of f1-f0/ma <- exp(1i*2* pi * f0 / fs);# starting at freq f0y <- czt(x, m, w, a)# compare DFT and FFTfs <-1000h <- as.numeric(fir1(100,125/(fs /2), type ="low"))m <-1024y <- stats::fft(postpad(h, m))f1 <-75; f2 <-175;w <- exp(-1i*2* pi *(f2 - f1)/(m * fs))a <- exp(1i*2* pi * f1 / fs)z <- czt(h, m, w, a)fn <- seq(0, m -1,1)/ m
fy <- fs * fn
fz =(f2 - f1)* fn + f1
plot(fy,10* log10(abs(y)), type ="l", xlim = c(50,200), xlab ="Frequency", ylab ="Magnitude (dB")lines(fz,10* log10(abs(z)), col ="red")legend("topright", legend = c("FFT","CZT"), col=1:2, lty =1)