%% 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]

%
% Create the interpolant F by passing the sample points and sample values to griddedInterpolant. With this setup, griddedInterpolant interprets V as containing three different 1-D data sets defined at the same x-values.

F = griddedInterpolant(x,V);

%
% Create a vector of query points with 0.5 spacing.

qx = 1:0.5:5;

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

Vq = F(qx)

% Copyright 2012 The MathWorks, Inc.