Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scattered data interpolation

I have a set of data for example:

X Y Z

1 3 7

2 5 8

1 4 9

3 6 10

I would like to interpolate Z for X=2.5 and Y=3.5 . How do i do it? I cannot use interp2 here because X and Y are not strictly monotonic (increasing or decreasing).

like image 618
user3222217 Avatar asked Jan 22 '14 06:01

user3222217


People also ask

What do you mean by interpolation of data?

Interpolation means determining a value from the existing values in a given data set. Another way of describing it is the act of inserting or interjecting an intermediate value between two other values.

What are the interpolation techniques used for evenly spaced data?

Linear interpolation is often used to regrid evenly-spaced data, such as longitude / latitude gridded data, to a higher or lower resolution.

What is an example of an interpolating data?

Based on the given data set, farmers can estimate the height of trees for any number of days until the tree reaches its normal height. For example, based on the above data, the farmer wants to know the tree's height on the 7th day. He can find it out by interpolating the above values.

What are the methods of interpolation in statistics?

There are several formal kinds of interpolation, including linear interpolation, polynomial interpolation, and piecewise constant interpolation.


2 Answers

The currently preferred way to perform scattered data interpolation is via the scatteredInterpolant object class:

>> F = scatteredInterpolant([1 2 1 3].',[3 5 4 6].',[7 8 9 10].','linear') %'
F = 
  scatteredInterpolant with properties:

                 Points: [4x2 double]
                 Values: [4x1 double]
                 Method: 'linear'
    ExtrapolationMethod: 'linear'
>> Zi = F(2.5,3.5)
Zi =
    6.7910

Alternate syntax,

>> P = [1 3 7; 2 5 8; 1 4 9; 3 6 10];
>> F = scatteredInterpolant(P(:,1:2),P(:,3),'linear')

For the advantages of scatteredInterpolant over griddata see this MathWorks page on Interpolating Scattered Data. In addition to syntactic differences, two main advantages are extrapolation and natural-neighbor interpolation. If you want to interpolate new data with the same interpolant, then you also have the performance advantage of reusing the triangulation computed when the interpolant object is created.

like image 83
chappjc Avatar answered Sep 26 '22 15:09

chappjc


It seems like griddata is the function you are looking for:

z = griddata( [1 2 1 3], [3 5 4 6], [7 8 9 10], 2.5, 3.5, 'nearest' )
like image 25
Shai Avatar answered Sep 25 '22 15:09

Shai