histogram for each column of 3d matrix

I have a 3d matrix containing 8*8*1000 elements. How can the histogram of desired binwidth be formed for each 1000 elements so that there should be a total of 8*8=64 histograms and storing just the data for each histogram (not plotting these)?

 Accepted Answer

Something like this, perhaps:
A=rand(8,8,1000); binwidth=0.1; %Fake input data
edges=0:binwidth:1;
Hist=num2cell(reshape(A,[],1000),2);
for i=1:64
Hist{i}=histcounts(Hist{i},edges);
end
Hist=reshape(cell2mat(Hist),8,8,[]); %the result
whos Hist
Name Size Bytes Class Attributes Hist 8x8x10 5120 double

More Answers (0)

Asked:

on 5 Oct 2023

Edited:

on 5 Oct 2023

Community Treasure Hunt

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

Start Hunting!