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 use tuples in JuliaLang?
- How to use lambda functions in JuliaLang?
- How to get JuliaLang version?
- How to test code in JuliaLang?
- How to convert a string to an integer in JuliaLang?
- How to create plots in JuliaLang?
- How to sort in JuliaLang?
- How to use regular expressions in JuliaLang?
- How to append to an array in JuliaLang?
- How to use the JuliaLang package manager?
See more codes...