binToVector and binToMatrix

版本 1.0.0.0 (1.7 KB) 作者: Karl Berggren
Provides functions that bin randomly sampled data to a reference grid for 1D and 2D data.
30.0 次下载
更新时间 2017/11/22

查看许可证

Provides two function that bin randomly sampled data to an equispaced reference grid that is either 1D (binToVector) or 2D (binToMatrix). Should work on older versions of MATLAB.
Scales the same way as the histcounts and accumarray method on the input data-set size but seems to provide a speed up of approximately a factor of 2 and less overhead for smaller data sets, at least in my implementation.

Inspired by binXYZonXY but should provide a speed improvement (https://www.mathworks.com/matlabcentral/fileexchange/41386-binning-a-point-cloud--3d-scattered-data--in-the-x-y-plane).

yB = binToVector(x,y,xB)
[yB, yBstd] = binToVector(x,y,xB)
[yB, yBstd, bin_population] = binToVector(x,y,xB)
Calculates yB = yB(xB) which is the binned version of y=y(x) using the
bin centers of the equispaced reference grid xB. The first and last bins
also include data half a bin width outside of the reference grid.
If the bin contains no elements, NaN is returned for that bin. Nan
elements in y are ignored. The input data x can be randomly sampled.

zB = binToMatrix(x,y,z,xB,yB)
[zB, zBstd] = binToMatrix(x,y,z,xB,yB)
[zB, zBstd, bin_population] = binToMatrix(x,y,z,xB,yB)
Calculates zB = zB(xB,yB) which is the binned version of the randomly
sampled function z=z(x,y). It uses the bin centers of the equispaced
reference grid xB,yB (created with meshgrid). The first and last bins
in each direction also include data half a bin width outside of the
reference grid. If the bin contains no elements, NaN is returned for
that bin. Nan elements in z are ignored.

Written by Karl Berggren, Royal Institute of Technology, Stockholm

引用格式

Karl Berggren (2025). binToVector and binToMatrix (https://www.mathworks.com/matlabcentral/fileexchange/65154-bintovector-and-bintomatrix), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2015b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Geology 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0