|
GRIDDATA Data gridding and surface fitting.
ZI = GRIDDATA(X,Y,Z,XI,YI) fits a surface of the form Z = F(X,Y) to the
data in the (usually) nonuniformly-spaced vectors (X,Y,Z). GRIDDATA
interpolates this surface at the points specified by (XI,YI) to produce
ZI. The surface always goes through the data points. XI and YI are
usually a uniform grid (as produced by MESHGRID) and is where GRIDDATA
gets its name.
XI can be a row vector, in which case it specifies a matrix with
constant columns. Similarly, YI can be a column vector and it specifies
a matrix with constant rows.
[XI,YI,ZI] = GRIDDATA(X,Y,Z,XI,YI) also returns the XI and YI formed
this way (the results of [XI,YI] = MESHGRID(XI,YI)).
[...] = GRIDDATA(X,Y,Z,XI,YI,METHOD) where METHOD is one of
'linear' - Triangle-based linear interpolation (default)
'cubic' - Triangle-based cubic interpolation
'nearest' - Nearest neighbor interpolation
'v4' - MATLAB 4 griddata method
defines the type of surface fit to the data. The 'cubic' and 'v4'
methods produce smooth surfaces while 'linear' and 'nearest' have
discontinuities in the first and zero-th derivative respectively. All
the methods except 'v4' are based on a Delaunay triangulation of the
data.
If METHOD is [], then the default 'linear' method will be used.
[...] = GRIDDATA(X,Y,Z,XI,YI,METHOD,OPTIONS) specifies a cell array
of strings OPTIONS to be used as options in Qhull via DELAUNAYN.
If OPTIONS is [], the default DELAUNAYN options will be used.
If OPTIONS is {''}, no options will be used, not even the default.
Example:
rand('seed',0)
x = rand(100,1)*4-2; y = rand(100,1)*4-2; z = x.*exp(-x.^2-y.^2);
ti = -2:.25:2;
[xi,yi] = meshgrid(ti,ti);
zi = griddata(x,y,z,xi,yi);
mesh(xi,yi,zi), hold on, plot3(x,y,z,'o'), hold off |
|