# Mid points of interval elements in interval vector

**URL:** <https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090>\
**Category:** General Usage\
**Tags:** question, intervals\
**Created:** [January 17, 2023, 1:10pm UTC](https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090 "2023-01-17T13:10:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kanishk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kanishk/32/46224_2.png) [@Kanishk](https://discourse.julialang.org/u/Kanishk)\
**Post date:** [January 17, 2023, 1:10pm UTC](https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090/1 "2023-01-17T13:10:28Z")

</div>

Hello,

I have an interval vector containing 10 interval elements ([0…50]). Now I want to get a vector containing the midpoints of all the interval elements. How to do it?

Thank you

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [January 17, 2023, 1:12pm UTC](https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090/2 "2023-01-17T13:12:12Z")

</div>

What package, if any, are you using for intervals? If none, how are you representing an interval?

---

<div class="post-metadata">

**Author:** ![Kanishk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kanishk/32/46224_2.png) [@Kanishk](https://discourse.julialang.org/u/Kanishk)\
**Post date:** [January 17, 2023, 1:15pm UTC](https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090/3 "2023-01-17T13:15:37Z")

</div>

I am using the “IntervalArithmetic.jl” package. I have a vector, vec = [(0…50), (0…50),…, (0…50)] of dimension 10\*1. I wish to get a vector mid\_vec = [25, 25,…,25] of the same dimension.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [January 17, 2023, 1:21pm UTC](https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090/4 "2023-01-17T13:21:37Z")

</div>

```julia
using IntervalArithmetic

v = [1.0..2.0, 2.0..4.0]
midpoints = map(mid, v)

```

```julia
julia> using IntervalArithmetic
julia> v = [1.0..2.0, 2.0..4.0];
julia> midpoints = map(mid, v)
2-element Vector{Float64}:
 1.5
 3.0

```

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [January 17, 2023, 1:38pm UTC](https://discourse.julialang.org/t/mid-points-of-interval-elements-in-interval-vector/93090/5 "2023-01-17T13:38:24Z")

</div>

Or `mid.(v)`.
