I am trying to vector differential equation in Julia. But I get stuck on the following error warning:
MethodError: no method matching hDerivative(::Array{Float64,1}, ::Nothing, >::Float64) Closest candidates are: hDerivative(::Any, ::Any) at In[8]:3 hDerivative(::Any) at In[13]:3
I am basically unsure about the syntax of the function "hDerivative". I tried returning the differential, but also to make to take "timederiv" as an argument of the function hDerivative, analogously to what I have seen in tuturials about differential equations in Julia, altough this look a little strange (I am used to python).
This is an example of the code I used:
using DifferentialEquations
N=10
J=randn(Float64,N,N)
g=1
function hDerivative(h,timederiv)
timederiv=zeros(Float64,N)
for i=1:length(h)
for j=1:length(h)
timederiv[i]=timederiv[i]+J[i,j]*tanh(h[j])
end
end
end
hinit=zeros(Float64,N)
tspan=(0.0,1.0)
prob = ODEProblem(hDerivative,hinit,tspan)
solve(prob)
Can anyone help me out?
function f(du,u,p,t)
, the return vector followed by the state vector and possibly paramters and the time. You have a different order and number of arguments. If you think that should work, please reference the example you are working off of. – Lutz Lehmannprob = ODEProblem((du,u,p,t)->hDerivative(u,du), hinit, tspan)
could work? – Lutz Lehmann