Geoscience Reference
In-Depth Information
plot(data(:,1),data(:,2),'ko')
text(data(:,1)+1,data(:,2),labels), hold off
title(titles(i,:))
end
According to the MATLAB documentation, h e MathWorks, Inc. has now
decided to move the linear (
linear
), the natural (
natural
) and the nearest
neighbor (
nearest
) techniques to the new function
scatteredInterpolant
, while
the biharmonic (
v4
) and cubic spline (
cubic
) options remain in the
griddata
function. In fact the code of
griddata
invokes the new
scatteredInterpolant
function instead of the original codes of
linear
,
natural
, or
nearest
. h e new
function works in a very similar manner to
griddata
, as we can easily explore
by typing
FLIN = scatteredInterpolant(data(:,1),data(:,2),data(:,3),...
'linear','linear');
FNEA = scatteredInterpolant(data(:,1),data(:,2),data(:,3),...
'nearest','nearest');
FNAT = scatteredInterpolant(data(:,1),data(:,2),data(:,3),...
'natural','none');
ZI(:,:,6) = FLIN(XI,YI);
ZI(:,:,7) = FNEA(XI,YI);
ZI(:,:,8) = FNAT(XI,YI);
titles(6:8,:) = ['scatlin';'scatnea';'scatnat'];
for i = 6:8
figure('Position',[350 (i-5)*100-50 500 300])
contourf(XI,YI,ZI(:,:,i),v), colorbar, hold on
plot(data(:,1),data(:,2),'ko')
text(data(:,1)+1,data(:,2),labels), hold off
title(titles(i,:))
end
Another very useful MATLAB gridding method is
splines with tension
by Wessel and Bercovici (1998), available for download from the author's
webpage:
http://www.soest.hawaii.edu/wessel/tspline/
h e
tsplines
use biharmonic splines in tension
t
, where the parameter
t
can vary between 0 and 1. A value of
t
=0 corresponds to a standard cubic
spline interpolation. Increasing
t
reduces undesirable oscillations between
data points, e.g., the paired
lows
and
highs
observed in one of the previous
examples. h e limiting situation
t
→1 corresponds to linear interpolation.