%% Replacement of Sample Values
% Replace the elements in the Values property when you want to change the values at the sample points. You get immediate results when you evaluate the new interpolant because the original triangulation does not change.
% Create 50 random points and sample an exponential function. These points are the sample values for the interpolant.

rng('default')
x = -2.5 + 5*rand([50 1]);
y = -2.5 + 5*rand([50 1]);
v = x.*exp(-x.^2-y.^2);

%
% Create the interpolant.

F = scatteredInterpolant(x,y,v)

%
% Evaluate the interpolant at (1.40,1.90).

F(1.40,1.90)

%
% Change the interpolant sample values and reevaluate the interpolant at the same point.

vnew = x.^2 + y.^2;
F.Values = vnew;
F(1.40,1.90)

% Copyright 2015 The MathWorks, Inc.