Counting number of individuals between a box
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Star Strider
il 27 Lug 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
.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!