Skip to content

No method matching curve_fit #215

@clemzm

Description

@clemzm

Hello ! I'm new to Julia and having trouble fitting a function of the form f(t,p)=p[1]+p[2]exp(-t/p[3]).
I tried to do this with curve_fit but I get the following error message:

f_exp(t::Float64,p::Vector{Float64})=p[1]+p[2]*exp(-t/p[3]);

p0=[1,1,0.5]
t=1:len

CurveFit.curve_fit(f_exp, t , P_TOD[1,:] , p0)

MethodError: no method matching curve_fit(::typeof(f_exp), ::UnitRange{Int64}, ::Vector{Float64}, ::Vector{Float64})
Closest candidates are:
curve_fit(::Type{Polynomial}, ::Any, ::Any, ::Any) at /home/heavybird/.julia/packages/CurveFit/JGc0o/src/linfit.jl:154
curve_fit(::Type{RationalPoly}, ::Any, ::Any, ::Any, ::Any) at /home/heavybird/.julia/packages/CurveFit/JGc0o/src/rationalfit.jl:92
curve_fit(::Type{RationalPoly}, ::Any, ::Any, ::Any, ::Any, ::Any) at /home/heavybird/.julia/packages/CurveFit/JGc0o/src/rationalfit.jl:92
...

Stacktrace:
[1] top-level scope
@ In[76]:6
[2] eval
@ ./boot.jl:360 [inlined]
[3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1116

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions