Extract center of the bin while 3D binning
3 views (last 30 days)
Show older comments
Taking it forward from here... https://www.mathworks.com/matlabcentral/answers/293645-how-to-sort-3d-data-into-bins
I have a set of xyz and corresponding "u" values for 3D binning. This is what I use to bin the variable u as shown below. Now from what I've understood, the binning takes place using bin edges. I would also like to find the center of each bin where the datapoints fall into. Ideally I want to have another variable which would store the bin-center values in the same format as the output U in this case.
xbins=min(x):binsize:max(x);
ybins=min(y):binsize:max(y);
zbins=min(z):binsize:max(z);
[~,~,cx]=histcounts(x,xbins);
[~,~,cy]=histcounts(y,ybins);
[~,~,cz]=histcounts(z,zbins); % generates indices for each direction.
U = accumarray([cx, cy, cz], u(:),[],@(vals){vals}, {});
Any help is appreciated.
Thanks!
0 Comments
Answers (1)
Sai Bhargav Avula
on 18 Feb 2020
Hi,
Assuming the exact center meaning the center of the dataset in the bin, the center can be estimated by finding mean of all the points in the mean(this is the centroid of the bin).
But if you mean the geometric center of the bin it is impossible to estimate to the best of my knowledge as there is not definite boundary of the boundary as the binning is done by thresholding.
Hope this helps!
0 Comments
See Also
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!