Mid points of interval elements in interval vector

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

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

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.

using IntervalArithmetic

v = [1.0..2.0, 2.0..4.0]
midpoints = map(mid, v)
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
1 Like

Or mid.(v).

1 Like