Home > ISET > utility > ffndgrid.m

ffndgrid

PURPOSE ^

FFNDGRID Fast 'n' Furious N-D data gridding.

SYNOPSIS ^

function [zzgrid, xvec] = ffndgrid(x, f, delta,limits,aver);

DESCRIPTION ^

FFNDGRID  Fast 'n' Furious N-D data gridding.

  CALL:  [fgrid, xvec] = ffndgrid(x,f, delta, limits, aver );

  fgrid = Matrix of gridded data.
  xvec  = cellarray of gridvectors 
           xl1:dx1:xu1 or linspace(xl1,xu1,Nx1) depending on delta.
  x     = [x1 x2,...xD] coordinate matrix for unevenly spaced data, f.
          size NxD. 
  f     = f(x), vector of function values length N.
  delta = [dx1+i*pad, dx2 ,...,dxD] or [-Nx1+i*pad -Nx2,...,NxD], where 
          dx1 to dxD and Nx1 to NxD defines the stepsize of grids and
          number of bins, respectively, in the D dimesional space. Empty
          gridpoints are padded with  IMAG(delta(1))=pad. (default -75) 
 limits = [xl1 xu1 xl2 ...xuN fl fu n0], contain the limits in the
          D-dimensional x1-x2...xN-f-plane of where to grid. The last
          parameter, n0, removes outliers from the data set by ignoring
          grid points with n0 or less observations. When n0 is negative
          it is treated as the percentage of the total number of data points.
          (default [min(x1),max(x1),min(x2),.... max(xN),min(f),max(f),0])
  aver  = 0 If each value of fgrid is the sum of all points falling
            within each cell.
          1 If each value of fgrid is the average of all points falling
            within each cell. (default)

 FFNDGRID grids unevenly spaced data in vector f into a matrix fgrid.

 NOTE: - The vector limits can be padded with NaNs if only
         certain limits are desired, e g if xl1 and fl are wanted:

            ffndgrid(x, f, [],[.5 nan nan nan 45])

       - If no output arguments are given, FFGRID will plot the gridded
         function with the prescribed axes using PCOLOR.

 Examples:
 N = 500;D=2; sz = [N ,D ];
 x = randn(sz); z = ones(sz(1),1); 
 [nc, xv] = ffndgrid(x,z,-15,[],0);  % Histogram
 pcolor(xv{:},nc)     %
 [XV,YV]=meshgrid(xv{:});
 text(XV(:),YV(:),int2str(nc(:)))
 dx = [diff(xv{1}(1:2)) diff(xv{2}(1:2))];
 contourf(xv{:}, nc/(N*prod(dx))) % 2-D probability density plot.
 colorbar
 colormap jet

 See also: griddata

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Sun 14-Jan-2007 10:24:23 by m2html © 2003