# How to analyze the solution?

**URL:** https://discourse.julialang.org/t/how-to-analyze-the-solution/77395
**Category:** General Usage
**Tags:** differentialequation
**Created:** [March 4, 2022, 11:03am UTC](https://discourse.julialang.org/t/how-to-analyze-the-solution/77395 "2022-03-04T11:03:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![egor](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/32.png) [@egor](https://discourse.julialang.org/u/egor)
#### Post date: [March 4, 2022, 11:03am UTC](https://discourse.julialang.org/t/how-to-analyze-the-solution/77395/1 "2022-03-04T11:03:15Z")

</div>

Hello everyone, I recently switched to julia from python and ran into a problem.  
I solve a parameterized system:

```julia
Γ(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](https://diffeq.sciml.ai/stable/tutorials/ode_example/#Step-3:-Analyzing-the-Solution) 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:

```julia
sizeof(sol.t)

```

and I get 4776. But when I try to access the element:

```julia
sol.t[4775]

```

I get the error:

```julia
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.

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [March 4, 2022, 11:07am UTC](https://discourse.julialang.org/t/how-to-analyze-the-solution/77395/2 "2022-03-04T11:07:31Z")

</div>

`sizeof` is the wrong function. You want `length`. (you can query the help with `?sizeof`)

`[uu[1] for uu in sol.u]` should give you the u1 vector (there are probably better ways). Then `findmax`.

Have a look at [Ordinary Differential Equations · DifferentialEquations.jl](https://diffeq.sciml.ai/stable/tutorials/ode_example/)
