Update dft
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
using Pkg
|
||||
Pkg.add("Plots")
|
||||
|
||||
using Plots
|
||||
|
||||
"""
|
||||
Start the program with
|
||||
julia -i HahnWitjesZettel6.4.jl
|
||||
"""
|
||||
|
||||
# https://en.wikipedia.org/wiki/Discrete_Fourier_transform#Definition
|
||||
function dft(x)
|
||||
N = length(x)
|
||||
@@ -23,13 +31,13 @@ function evaluate_coefficients(x, coeffs)
|
||||
end
|
||||
|
||||
function f(n)
|
||||
xs = (0:n-1) ./ n
|
||||
xs = (0:n-1) ./ n # Exclude the last one
|
||||
[x < 1/2 ? (x, x) : (x, 1 - x) for x in xs]
|
||||
end
|
||||
|
||||
function main()
|
||||
ns = [3, 6, 10, 15, 20, 25]
|
||||
plt = plot(layout = (length(ns), 2), size = (1000, 1000))
|
||||
plt = plot(layout = (length(ns), 2), size = (1200, 1000))
|
||||
|
||||
for (row, n) in enumerate(ns)
|
||||
points = f(n)
|
||||
@@ -45,7 +53,7 @@ function main()
|
||||
plt[row, 1],
|
||||
xfine,
|
||||
real.(poly),
|
||||
title = "n = $n (real part)",
|
||||
title = "n = $n (Realteil)",
|
||||
legend = false
|
||||
)
|
||||
scatter!(
|
||||
@@ -57,14 +65,13 @@ function main()
|
||||
plt[row, 2],
|
||||
xfine,
|
||||
imag.(poly),
|
||||
title = "n = $n (imag part)",
|
||||
title = "n = $n (Imaginaerteil)",
|
||||
legend = false
|
||||
)
|
||||
end
|
||||
|
||||
gui(plt)
|
||||
savefig("HahnWitjesZettel6.4.svg")
|
||||
end
|
||||
|
||||
main()
|
||||
|
||||
|
||||
gui()
|
||||
1096
src/Manifest.toml
Normal file
1096
src/Manifest.toml
Normal file
File diff suppressed because it is too large
Load Diff
2
src/Project.toml
Normal file
2
src/Project.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[deps]
|
||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
Reference in New Issue
Block a user