Count number of elements in y-axis that correspond to a range of elements in x-axis
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
AUWAL ABUBAKAR
le 1 Juil 2019
Commenté : AUWAL ABUBAKAR
le 2 Juil 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 commentaire
Réponse acceptée
Alex Mcaulley
le 1 Juil 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...)
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!