Count number of elements in y-axis that correspond to a range of elements in x-axis
1 回表示 (過去 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!