Hello everyone, I recently switched to julia from python and ran into a problem.
I solve a parameterized system:
Γ(x, λ, Θ) = 1 / (1 + exp(-λ*(x - Θ)))
function parametrized_2hr!(du, u, p, t)
a = p[1]; b = p[2]; c = p[3]; d = p[4]; xr = p[5]; r = p[6]; s = p[7]; I = p[8]; vs = p[9]; λ = p[10]; Θ = p[11];
k1 = p[12]; k2 = p[13]; k = p[14]
du[1] = u[2]+b*u[1]^2-a*u[1]^3-u[3]+I-k1*(u[1]-vs)*Γ(u[4], λ, Θ)+k*(u[4]-u[1])
du[2] = c-d*u[1]^2-u[2]
du[3] = r*(s*(u[1]-xr)-u[3])
du[4] = u[5]+b*u[4]^2-a*u[4]^3-u[6]+I-k2*(u[4]-vs)Γ(u[1], λ, Θ)+k*(u[1]-u[4])
du[5] = c-d*u[4]^2-u[5]
du[6] = r*(s*(u[4]-xr)-u[6])
end
u0 = [-1.5, 0.0, 0.0, -1.5, 0.0, 0.0]
tspan = (0.0, 100.0)
p = [1.0, 3.0, 1.0, 5.0, -1.6, 0.01, 5.0, 4.0, 2.0, 10.0, -0.25, -0.17, -0.17, 0.0]
prob = ODEProblem(parametrized_2hr!,u0,tspan,p)
sol = solve(prob, reltol=1e-6)
I read this documentation but still don’t understand how can I get an array for each variable: t, u1, u2, u3, u4, u5, u6?
For example, I write:
sizeof(sol.t)
and I get 4776. But when I try to access the element:
sol.t[4775]
I get the error:
BoundsError: attempt to access 597-element Vector{Float64} at index [4775]
Can you please explain what I am doing wrong and how to process the output correctly? For example, if I need to take the variable u1 and discard the first few values, and then find the local maxima.