julialangHow to use JuliaLang to perform a Fast Fourier Transform?
JuliaLang provides a package called FFTW
to perform Fast Fourier Transform (FFT). To use it, first install the package by running Pkg.add("FFTW")
in the Julia REPL. Then, import the package by running using FFTW
in the Julia REPL.
To perform a FFT, use the fft
function. For example, to perform a FFT on a vector x
, run y = fft(x)
.
julia> using FFTW
julia> x = [1,2,3,4]
4-element Array{Int64,1}:
1
2
3
4
julia> y = fft(x)
4-element Array{Complex{Float64},1}:
10.0+0.0im
-2.0+2.0im
-2.0+0.0im
-2.0-2.0im
Code explanation
Pkg.add("FFTW")
: install theFFTW
packageusing FFTW
: import theFFTW
packagefft(x)
: perform a FFT on a vectorx
Helpful links
More of Julialang
- How to test code in JuliaLang?
- How to use tuples in JuliaLang?
- How to append to an array in JuliaLang?
- How to use assert in JuliaLang?
- How to calculate the mean in JuliaLang?
- How to get JuliaLang version?
- How to use try catch in JuliaLang?
- How to round numbers in JuliaLang?
- How to work with matrices in JuliaLang?
- How to create a histogram in JuliaLang?
See more codes...