Skip to content

Instantly share code, notes, and snippets.

@JayKickliter
Created April 3, 2014 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayKickliter/9962068 to your computer and use it in GitHub Desktop.
Save JayKickliter/9962068 to your computer and use it in GitHub Desktop.
# function czt( x::Vector )
x = ones(8)
N = length( x )
M = nextpow2( 2*N - 1 )
xx = zeros( Complex128, M )
yy = zeros( Complex128, M )
for n = 1:N
xx[n] = x[n]
yy[n] = exp( im * π/N * (n-1)^2 )
end
for n = 1-N:-1
yy[M+n+1] = exp( im*π/N*n*n )
end
for n = 1:N
xx[n] = x[n]*exp( -im*π/N*(n-1)^2 )
end
XX = fft( xx )
YY = fft( yy )
X = XX.*YY
X = ifft( X )
X = [ X[n] * exp( im*π/N*(n-1)^2 ) for n = 1:M ]
X = X[1:N]
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment