JuliaMath / Interpolations.jl

Fast, continuous interpolation of discrete datasets in Julia
http://juliamath.github.io/Interpolations.jl/
Other
518 stars 110 forks source link

Cubic spline interpolation for Vector Type x #588

Open kongdd opened 5 months ago

kongdd commented 5 months ago
julia> using Interpolations
       # Plots

       # Lower and higher bound of interval
       a = 1.0
       b = 10.0
       # Interval definition
       x = collect(a:1.0:b)
       # This can be any sort of array data, as long as
       # length(x) == length(y)
       y = @. cos(x^2 / 9.0) # Function application by broadcasting
       # Interpolations
       itp_linear = linear_interpolation(x, y)
       itp_cubic = cubic_spline_interpolation(x, y)
ERROR: MethodError: no method matching cubic_spline_interpolation(::Vector{Float64}, ::Vector{Float64})

Closest candidates are:
  cubic_spline_interpolation(::Tuple{Vararg{AbstractRange, N}}, ::AbstractArray{T, N}; bc, extrapolation_bc) where {N, T}
   @ Interpolations C:\Users\kong\.julia\packages\Interpolations\91PhN\src\convenience-constructors.jl:28
  cubic_spline_interpolation(::AbstractRange, ::AbstractVector; bc, extrapolation_bc)
   @ Interpolations C:\Users\kong\.julia\packages\Interpolations\91PhN\src\convenience-constructors.jl:11