Counting number of individuals between a box

1 vue (au cours des 30 derniers jours)
Jonathan Demmer
Jonathan Demmer le 27 Juil 2020
Hello,
I have 7000 particles scattered in an area. I would like to count the number of them in one particular area delimited by fixed coordinates. For example:
Particles number Coordinates X Coordinates Y
1 25 58
2 18 30
3 5 45
4 26 60
5 27 61
6 14 70
How many particles are located in the area: 20<x<30 and 57<y<71? The aswer should be: 3
Thank you for your help.
Jonathan

Réponses (1)

Star Strider
Star Strider le 27 Juil 2020
Try this:
A = [1 25 58
2 18 30
3 5 45
4 26 60
5 27 61
6 14 70];
Count = nnz(A(:,2)>20 & A(:,2)<30 & A(:,3)>57 & A(:,3)<71)
producing:
Count =
3
.

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by