File Exchange

image thumbnail


version 1.2 (2.28 KB) by

Create a matrix from scattered data without interpolation



View License

BIN2MAT can be used to create a grid from scattered 2D data using grid-cell averaging (no interpolation). BIN2MAT also accepts function handles so you can evaluate many different functions over each grid cell. If the specified function returns non-scalar output, BIN2MAT will return a cell array.

EXAMPLE (generates screen-shot)

 %generate some scattered data
     xs=x(ind); ys=y(ind); zs=z(ind);
%create a grid
%calculate the mean and standard deviation
%for each grid-cell using bin2mat
     Zm=bin2mat(xs,ys,zs,XI,YI); %mean
     Zs=bin2mat(xs,ys,zs,XI,YI,@std); %std
%plot the results
     axis image
     title('Scatter Data')
     shading flat
     axis image
     title('Grid-cell Average')
     shading flat
     axis image
     title('Grid-cell Std. Dev.')

Comments and Ratings (1)

Guillaume MAZE

Guillaume MAZE (view profile)



modified error-checking, also add a check to make sure x,y,z inputs are column (m x 1) vectors.

MATLAB Release
MATLAB 7.8 (R2009a)

Inspired: CURVVEC

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video