How to approximate a noisy spectrum

This is giving indeed a much more streightforward approximation:

using PythonPlot, FastChebInterp

f_ex = 0.2

N = 10
Ts = 0.5
tmax = (N-1) * Ts
t = 0:Ts:tmax
signal = sin.(2π * f_ex .* t) # sin (2π f t)

f = chebregression(t, signal, 5)

plot(t, signal, label = "Signal")
t1=0.0:0.01:4.5
plot(t1, f.(t1), label = "Approximation")
legend()
grid(true)

Thanks for the hint!

1 Like