Geoscience Reference
In-Depth Information
a spline, i.e., a third-degree 3D polynomial is i tted to at least six adjacent
control points, resulting in a surface (and its i rst derivative) that is continuous.
h e resulting surface is much smoother than those calculated using linear
(
linear
), natural (
natural
), or nearest neighbor (
nearest
) techniques but not
as smooth as that resulting from a biharmonic spline interpolation (
v4
). For
this reason the typical artifacts of splines do not occur to the same extent.
We can compare all of these methods in the next example. We i rst clear the
workspace and reload the data from
normalfault.txt
.
clear
data = load('normalfault.txt');
data(79,:) = [450 105 5];
labels = num2str(data(:,3),2);
We then create titles for the results from the dif erent interpolation methods.
titles = ['linear ';'nearest';'natural';'cubic ';'biharmo'];
Since we store the titles in a single character array, we use spaces to expand
the names of the methods so that they are all the same length. We again dei ne
the axis limits for gridding and contouring:
xlim
=[420 470] and
ylim
=[70
120]. h e function
meshgrid
transforms the domain specii ed by vectors
x
and
y
into arrays
XI
and
YI
. h e rows of the output array
XI
are copies of the
vector
x
and the columns of the output array
YI
are copies of the vector
y
. We
choose 1.0 as the grid interval.
x = 420:1:470; y = 70:1:120;
[XI,YI] = meshgrid(x,y);
We then use
griddata
with all available options and store the results in a
three-dimensional array
ZI
.
ZI(:,:,1) = griddata(data(:,1),data(:,2),data(:,3),XI,YI,'linear');
ZI(:,:,2) = griddata(data(:,1),data(:,2),data(:,3),XI,YI,'nearest');
ZI(:,:,3) = griddata(data(:,1),data(:,2),data(:,3),XI,YI,'natural');
ZI(:,:,4) = griddata(data(:,1),data(:,2),data(:,3),XI,YI,'cubic');
ZI(:,:,5) = griddata(data(:,1),data(:,2),data(:,3),XI,YI,'v4');
We compare the results in i ve dif erent graphics in separate i gure windows,
slightly of set on the computer display, using
figure
. h e data are displayed
as i lled contours at values specii ed in a vector
v
.
v = -40 : 10 : 20;
for i = 1 : 5
figure('Position',[50 i*100-50 500 300])
contourf(XI,YI,ZI(:,:,i),v), colorbar, hold on