binToVector and binToMatrix
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
Zitieren als
Karl Berggren (2024). binToVector and binToMatrix (https://www.mathworks.com/matlabcentral/fileexchange/65154-bintovector-and-bintomatrix), MATLAB Central File Exchange. Abgerufen .
Kompatibilität der MATLAB-Version
Plattform-Kompatibilität
Windows macOS LinuxKategorien
- Sciences > Geoscience > Geology >
Tags
Quellenangaben
Inspiriert von: binning a point cloud, 3D scattered data, in the X-Y plane
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.0.0.0 |