Interpolation in N dimension

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Interpolation in N dimension

Damir
Hello,
I'm trying to use "interpn function" and probing even a simple 2D example in
the att.  I cannot reproduce the interpolation value FUN(xi,yi)  compared to
the matrix grid value i.e. FUN(1,11) != 4. Would appreciate advice on this,
cheers, Damir


Code

--------------------

A = [13,-1,12;5,4,3;1,6,2];

x = [0,1,2];
y = [10,11,12];

xi = linspace (min (x), max (x), 30);
yi = linspace (min (y), max (y), 60);
FUN = interpn (x, y, A, xi, yi, "spline");


disp("value(1,11) = "), FUN(1, 11)




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Interpolation in N dimension

Michele Ginesi
On 10/1/19 11:51 AM, Damir wrote:

> Hello,
> I'm trying to use "interpn function" and probing even a simple 2D example in
> the att.  I cannot reproduce the interpolation value FUN(xi,yi)  compared to
> the matrix grid value i.e. FUN(1,11) != 4. Would appreciate advice on this,
> cheers, Damir
>
>
> Code
>
> --------------------
>
> A = [13,-1,12;5,4,3;1,6,2];
>
> x = [0,1,2];
> y = [10,11,12];
>
> xi = linspace (min (x), max (x), 30);
> yi = linspace (min (y), max (y), 60);
> FUN = interpn (x, y, A, xi, yi, "spline");
>
>
> disp("value(1,11) = "), FUN(1, 11)
>
Hi,

that's because FUN is a matrix (you already evaluated the interpolator
in (xi,yi)). When you call FUN(1,11) you are showing the function
interpolated at (xi(1), yi(11)) = (0, 10.339), not at (xi,yi)=(1,11).

Michele

>
>
> --
> Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
>
>