Count number of elements in y-axis that correspond to a range of elements in x-axis
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Alex Mcaulley
2019-7-1
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...)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!