File Exchange

image thumbnail

qgriddata

version 1.0.0.0 (1.06 KB) by Tim Hattrell
Quick data gridding for unevenly distributed data sets

1 Download

Updated 17 Mar 2006

No License

This function takes unevenly distributed data in vectors X,Y,Z,V and returns data in arrays XG,YG,ZG,VG which are suitable for use in Matlab functions such as SLICE.

For any valid I, X(I),Y(I),Z(I),V(I) defines the x,y and z coordinates of data with a scalar value V(I) associated with that coordinate.

This function is much faster than using GRIDDATA for large data sets as it does not attempt any interpolation. Instead, the function searches for data points which fall in a particular cell of dimensions DX,DY,DZ. The mean of all the points in the cell is returned in VG. If there are no data points inside that volume then NaN is returned, i.e. THERE IS NO INTERPOLATION. For this reason, if DX,DY or DZ are set too small the function will not be effective.

Cite As

Tim Hattrell (2021). qgriddata (https://www.mathworks.com/matlabcentral/fileexchange/10399-qgriddata), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

John D'Errico

This is VERY slow compared to what it could be. You will want a fine grid because of the coarse aggregation. Also very much data, otherwise there will be many holes in the resulting grid. This code may be reasonable for problems with very noisy data, where an interpolant will produce a mess. Beware surfaces with high curvature, as the averaging will flatten them out.

Why use a triple loop over all the cells to do what 3 calls to floor will do for you? I.e., since the grid is equally spaced, subtract the minimum, divide by the spacing, then call floor, and add 1. This provides an index in each dimension for every data point. Now use any strategy you want to accumulate the mean of all points in a given cell. Since this works in 3-d, sparse or accumarray are not options (unless you use a reshape, which will then work very efficiently.)

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: plot3c

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!