If the two-dimensional data does not exist on a uniform grid, methods such as
surf will not be applicable. MATLAB provides functionality to fit scatter points with a uniform grid and thereby facilitate the use of the standard techniques to 2D visualization on such data, as shown in this recipe.
Generate a scattered dataset in 2D space:
load griddataExample; R = sqrt(x.^2 + y.^2) + eps; z = sin(R)./R;
Perform the following steps:
xx = linspace(min(x),max(x),30); yy = linspace(min(y),max(y),30); [X,Y] = meshgrid(xx,yy);
Z_griddata = griddata(x,y,z,X,Y);