How to create a loop generating bins for the group of data in cell array
Show older comments
Hi everyone,
I am a newby to MathLab and I need some help from the community.
I am trying to figure out how to loop a simple histcounts function.
I have a data set which I separtated into cell arrays with accumarrays
So now I have a cell array GC{121:1} which contain 121 separate matrixes (double values). Each of those matrixes has 2 columns and diferent numer of rows (2 x n matrix ).The first colunm is the number of slice indicating were data were extracted from.
I would like to split each matrix into 10 equal bins by the second column. So far I got to this:
But the loop I wrote dose not work
GC = accumarray(data(:,1),(1:size(data,1)),[],@(x){data(x,:)});
% Distribute x_point column into 6 equally spaced bins..
for i=1:121
[N,edges] = histcounts(GC{i,1},10);
end
3 Comments
dpb
on 25 Apr 2020
What does "does not work" mean, specifically?
Looks like it should work just fine as far as running although you're overwriting the return variables [N,edges] every pass through the loop so at the end you only have the last result....is that the problem?
Save the results in another set of cell arrays.
Iuliia Myrgorodska
on 25 Apr 2020
Iuliia Myrgorodska
on 25 Apr 2020
Accepted Answer
More Answers (0)
Categories
Find more on Data Distribution Plots 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!