In a random distribution of points in square area how can we determine the density information of points in each region

조회 수: 10 (최근 30일)
I want to distribute random points in a square region and then determine the density information of the points array form such that a density function can be defined for the most important points and least important points. for example in a 2D square area of 100x100 divide into four quardrants.
Lets say uniform random distribution of 100 points gives me 25 points in each quardrant (assumption). based on the distance from each other the points will be dense in certain area of quardrant but less dense in other I wish to define a density function which will highlight the importance of some points on others.
I know it might seem like a dispersed idea but could anyone give any relevant commants and codes that could help?
Thank you for taking time in reading.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 9월 3일
So this is simply counting the number of points in each region. You can do this "by hand" region-by-region, something like this:
n_points = 5000;
r_point = rand(n_points,2);
reg_lims1 = [0 0.2 0.1 0.5];
dens_reg1 = find(reg_lims1(1)<=r_point(:,1)&r_point(:,1)<reg_lims1(2)&...
reg_lims1(3)<=r_point(:,2)&r_point(:,2)<reg_lims1(4));
which requires you to do the work. Or you could use histogram2.
HTH
  댓글 수: 2
Tamoor Shafique
Tamoor Shafique 2020년 9월 3일
Thank you will need some work doing but this is something in the same direction as I wish to do
Bjorn Gustavsson
Bjorn Gustavsson 2020년 9월 3일
The "manual" method would require you to define a couple of region-boundaries, then to count up all points inside each region. If you use histogram2 or histcount2 you get most of that work done for you. Read the help and documentation to histogram2 or histcount2 to see how to adapt the call to those functions to do exactly what you need, then how to continue with the output from either of those functions to get the result in your desired form.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bruno Luong
Bruno Luong 2020년 9월 3일
Checkout histcounts2

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by