# ScatteredInterpolation - basic example from docs not working

**URL:** <https://discourse.julialang.org/t/scatteredinterpolation-basic-example-from-docs-not-working/94726>\
**Category:** Numerics\
**Tags:** interpolations\
**Created:** [February 16, 2023, 3:11pm UTC](https://discourse.julialang.org/t/scatteredinterpolation-basic-example-from-docs-not-working/94726 "2023-02-16T15:11:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wave\_and\_matter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wave_and_matter/32/202530_2.png) [@wave\_and\_matter](https://discourse.julialang.org/u/wave_and_matter)\
**Post date:** [February 16, 2023, 3:11pm UTC](https://discourse.julialang.org/t/scatteredinterpolation-basic-example-from-docs-not-working/94726/1 "2023-02-16T15:11:14Z")

</div>

I have tried to use the ScatteredInterpolation package.  
When i duplicate the first simple example from the documentation [Home · ScatteredInterpolation.jl](https://eljungsk.github.io/ScatteredInterpolation.jl/stable/)

```julia
using ScatteredInterpolation
samples = [0.0; 0.5; 0.5; 0.5; 1.0];
points = [0.0 0.0; 0.0 1.0; 1.0 0.0; 0.5 0.5; 1.0 1.0];
itp = interpolate(Multiquadratic(), points, samples);

```

I get

```julia
DimensionMismatch: arguments must have the same number of rows

Stacktrace:
 [1] \(F::LinearAlgebra.LU{Float64, Matrix{Float64}, Vector{Int64}}, B::Vector{Float64})
   @ LinearAlgebra ~/bin/julia-1.8.4/share/julia/stdlib/v1.8/LinearAlgebra/src/LinearAlgebra.jl:472
 [2] \(A::Matrix{Float64}, B::Vector{Float64})
   @ LinearAlgebra ~/bin/julia-1.8.4/share/julia/stdlib/v1.8/LinearAlgebra/src/generic.jl:1110
 [3] solveForWeights
   @ ~/.julia/packages/ScatteredInterpolation/tlSER/src/rbf.jl:249 [inlined]
 [4] interpolate(rbf::Multiquadratic{Int64}, points::Matrix{Float64}, samples::Vector{Float64}; metric::Distances.Euclidean, returnRBFmatrix::Bool, smooth::Bool)
   @ ScatteredInterpolation ~/.julia/packages/ScatteredInterpolation/tlSER/src/rbf.jl:201
 [5] interpolate(rbf::Multiquadratic{Int64}, points::Matrix{Float64}, samples::Vector{Float64})
   @ ScatteredInterpolation ~/.julia/packages/ScatteredInterpolation/tlSER/src/rbf.jl:185
 [6] top-level scope
   @ In[11]:3

```

I wonder what i am missing here. Am i doing something wrong? Is the documentation showing some deprecated syntax here? Is the whole package broken?

---

<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:** [February 16, 2023, 3:17pm UTC](https://discourse.julialang.org/t/scatteredinterpolation-basic-example-from-docs-not-working/94726/2 "2023-02-16T15:17:39Z")

</div>

Works fine for me:

```julia
julia> using ScatteredInterpolation

julia> samples = [0.0; 0.5; 0.5; 0.5; 1.0];

julia> points = [0.0 0.0; 0.0 1.0; 1.0 0.0; 0.5 0.5; 1.0 1.0]'
2×5 adjoint(::Matrix{Float64}) with eltype Float64:
 0.0 0.0 1.0 0.5 1.0
 0.0 1.0 0.0 0.5 1.0

julia> itp = interpolate(Multiquadratic(), points, samples)
ScatteredInterpolation.RBFInterpolant{Vector{Float64}, LinearAlgebra.Adjoint{Float64, Matrix{Float64}}, Multiquadratic{Int64}, Distances.Euclidean}([0.9386823120387296, 0.2556696101465102, 0.2556696101465102, -0.7525201751905015, -0.42734309174570895], [0.0 0.0 … 0.5 1.0; 0.0 1.0 … 0.5 1.0], Multiquadratic{Int64}(1), Distances.Euclidean(0.0))

julia> interpolated = evaluate(itp, [0.6; 0.6])
1-element Vector{Float64}:
 0.6105036860019829

```

It looks to me like you’ve just made an error copy pasting from the docs - you are missing a transpose (`'`) in the definition of `points`.

---

<div class="post-metadata">

**Author:** ![wave\_and\_matter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wave_and_matter/32/202530_2.png) [@wave\_and\_matter](https://discourse.julialang.org/u/wave_and_matter)\
**Post date:** [February 17, 2023, 8:32am UTC](https://discourse.julialang.org/t/scatteredinterpolation-basic-example-from-docs-not-working/94726/3 "2023-02-17T08:32:08Z")

</div>

This is the working solution, thanks and sorry for missing this simple error.
