2.0

2.0 | 1 rating Rate this file 2 Downloads (last 30 days) File Size: 2.01 KB File ID: #10399

qgriddata

by Tim Hattrell

 

17 Mar 2006 (Updated 17 Mar 2006)

Quick data gridding for unevenly distributed data sets

| Watch this File

File Information
Description

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.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
plot3c

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
17 Mar 2006 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.)

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
specialized Tim Hattrell 22 Oct 2008 08:18:49
plotting Tim Hattrell 22 Oct 2008 08:18:49
uneven grid cfd 3d 3d data gridding resample unevenly distribute Tim Hattrell 22 Oct 2008 08:18:49

Contact us at files@mathworks.com