Julia vs GNU Octave for plot fitting / finding peaks

You can easily find the frequency using, e.g., the ESPRIT method

using DSP
y = sin.(0:0.1:10) .+ 0.1 .* randn.()
esprit(y, 10, 2)

julia> esprit(y, 10, 2)
2-element Array{Float64,1}:
 -0.015982377052346328
  0.015982377052346328

julia> 0.1/(2pi)
0.015915494309189534

After that, it’s a simple least-squares problem to find the coefficients in the model

k_s \sin(\omega t) + k_c \cos(\omega t)

1 Like