Count number of elements in y-axis that correspond to a range of elements in x-axis
2 views (last 30 days)
Show older comments
AUWAL ABUBAKAR
on 1 Jul 2019
Commented: AUWAL ABUBAKAR
on 2 Jul 2019
Good day,
Please I have a challenge. am working on image processing. I plotted Distance against Time data. I would like to count the number of elements (Distance values) in y-axis that falls within each minute (0 to 1, 1 to 2, 2 to 3 mins and so on) on the x-axis
I know i can use indext = find (Time==1); ypoint=Distance(index) to get the correpsnding element on the y-axis. But this doesnt give me the elements in y-axis that correspnt to 0 to 1min nor to use numel to count the elements.
Can someone help me on this please?
1 Comment
Accepted Answer
Alex Mcaulley
on 1 Jul 2019
If you have:
x % -> time
y % -> distances
edges = 0:maxTime; % Define de edges you want to define the bins
[N,~,bin] = histcounts(x,edges)
%where N gives the number of elements in each bin
%and bin gives in which bin is each element of x (or y...)
More Answers (0)
See Also
Categories
Find more on Image Filtering and Enhancement 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!