I want to generate a circel which filled with regular points say 1000 points inside the circel. The point to another will be constant. How can I generate this? Thanks in advance.
The distance from one particles to another will be constant.
In order to get that, you need to construct a hexagon packing in a circle: https://math.stackexchange.com/questions/1283085/hexagon-packing-in-a-circle and put the particles at the vertices. That will put each point at the same distance relative to the three closest points around it (except at the edge.) This is the densest possible packing.
Perhaps for your purposes it would be good enough to construct a square mesh.
Do not place the points randomly: you will not be able to satisfy the rule that the distance from one particle to another is constant.
That diagram does not have each point a constant distance to the next point along the angle, and the number of points along the radii changes as you go outwards.
For any given radius, calculate the circumference of the circle at that radius (2*pi*R) and divide by the constant distance, and take the floor. This is the number of points, N, to place along that radius. Now linspace(0,2*pi,N+1) to get theta values, and use pol2cart() with those theta values and the current radius. You know have a set of X Y coordinates to put the markers at. Repeat for all of the different radiuses.
You could use the Parallel Processing Toolbox to compute the points along different radii in parallel, and then bring the computed points all back together into the main thread for plotting. However this is very likely to be slower than doing it all in one thread.
The algorithm that I described earlier for placing the points has a flaw: it does not place the points at constant radial distance apart from each other as you required. Placing an integer number of points at constant distance along circles can only be done at very carefully selected radii, except that the task is made easier if the constant distance is a simple fraction of Pi.
The algorithm I described earlier does not use constant distance: at each radius it modifies the constant distance slightly to get the closest approximation of the distance that permits an exact integer number of points to be placed.
The number of points that are appropriate for each radius will differ, and the appropriate number would be the same for two radii only if the two radii differ by less than 1/(2*pi) approximately.
The calculation of linspace(0,2*pi,N+1) is difficult to vectorize for multiple N values.
It would be possible to use the same N value for multiple radii even though they "should" have different N values, but if you do so then you have the problem that the "constant distance" requirement gets more and more violated.
What might be worth doing is calculating all of the points for each radii in a loop, storing the results in a cell array, then cell2mat() to create a single list of x and single list of y coordinates, and scatter() with that -- thus reducing down to a single scatter object instead of one per radius.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.