Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No method matching curve_fit #215

Open
clemzm opened this issue Jun 3, 2022 · 1 comment
Open

No method matching curve_fit #215

clemzm opened this issue Jun 3, 2022 · 1 comment

Comments

@clemzm
Copy link

clemzm commented Jun 3, 2022

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

@pkofod
Copy link
Member

pkofod commented Sep 3, 2022

Sorry that I didn't get to you sooner, but you could use a vector type for x, so t = collect(1:len) would work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants