Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

arrays - 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).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...