Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

Interpolation of Multiple 1-D Value Sets

This example shows how to interpolate three 1-D data sets in a single pass using griddedInterpolant. This is a faster alternative to looping over your data sets.

Define the x-coordinates that are common to all value sets.

x = (1:5)';

Define the sets of sample points along the columns of matrix V.

V = [x, 2*x, 3*x]
V =

     1     2     3
     2     4     6
     3     6     9
     4     8    12
     5    10    15

Create a 2-D grid of sample points.

samplePoints = {x, 1:size(V,2)};

This compact notation specifies a full 2-D grid. The first element, samplePoints{1}, contains the x-coordinates for V, and samplePoints{2} contains the y-coordinates. The orientation of each coordinate vector does not matter.

Create the interpolant, F, by passing the sample points and sample values to griddedInterpolant.

F = griddedInterpolant(samplePoints,V);

Create a 2-D query grid with 0.5 spacing along x over all columns of V.

queryPoints = {(1:0.5:5),1:size(V,2)};

Evaluate the interpolant at the x-coordinates for each value set.

Vq = F(queryPoints)
Vq =

    1.0000    2.0000    3.0000
    1.5000    3.0000    4.5000
    2.0000    4.0000    6.0000
    2.5000    5.0000    7.5000
    3.0000    6.0000    9.0000
    3.5000    7.0000   10.5000
    4.0000    8.0000   12.0000
    4.5000    9.0000   13.5000
    5.0000   10.0000   15.0000

See Also

Related Examples

Was this topic helpful?