Count number of elements in y-axis that correspond to a range of elements in x-axis

1 visualización (últimos 30 días)
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?

Respuesta aceptada

Alex Mcaulley
Alex Mcaulley el 1 de Jul. de 2019
Using histcounts:
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...)

Más respuestas (0)

Categorías

Más información sobre Image Filtering and Enhancement en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by