# How do I use 'pchip' interpolation of Matlab in Julia code?

**URL:** <https://discourse.julialang.org/t/how-do-i-use-pchip-interpolation-of-matlab-in-julia-code/114688>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 24, 2024, 4:20pm UTC](https://discourse.julialang.org/t/how-do-i-use-pchip-interpolation-of-matlab-in-julia-code/114688 "2024-05-24T16:20:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hyde/32/52754_2.png) [@hyde](https://discourse.julialang.org/u/hyde)\
**Post date:** [May 24, 2024, 4:20pm UTC](https://discourse.julialang.org/t/how-do-i-use-pchip-interpolation-of-matlab-in-julia-code/114688/1 "2024-05-24T16:20:56Z")

</div>

In Matlab, there is ‘pchip’ interpolation method.  
How do I can use ‘pchip’ interpolation by Julia code.  
I tried some guide such as ‘‘[GitHub - gerlero/PCHIPInterpolation.jl: Monotonic cubic interpolation in Julia](https://github.com/gerlero/PCHIPInterpolation.jl)’’ found by searching google, it was not helpful. Following those suggestions just gave me continuous errors.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 24, 2024, 5:29pm UTC](https://discourse.julialang.org/t/how-do-i-use-pchip-interpolation-of-matlab-in-julia-code/114688/2 "2024-05-24T17:29:34Z")

</div>

You’ll have to be a bit more precise on the errors. I just installed the package and tried the example from the readme on Julia 1.10.3 and got:

```julia
julia> using PCHIPInterpolation

julia> xs = [0.0, 1.2, 2.0, 5.0, 10.0, 11.0];

julia> ys = [2.0, 2.1, 1.0, 0.0, 0.0, 3.0];

julia> itp = Interpolator(xs, ys)
Interpolator{Vector{Float64}, Vector{Float64}, Vector{Float64}}([0.0, 1.2, 2.0, 5.0, 10.0, 11.0], [2.0, 2.1, 1.0, 0.0, 0.0, 3.0], [0.2500000000000002, 0.0, -0.6081474296799224, 0.0, 0.0, 3.5])

julia> ys = itp.(xs) # At multiple points
6-element Vector{Float64}:
 2.0
 2.1
 1.0
 0.0
 0.0
 3.0

```

which seems fine to me?
