how can i place NxN particles randomly on a two dimensional plane?

11 Comments

Are they square particles? Round particles? What is the size of the grid? Are they to go at integer coordinates? Are there restrictions on minimum distances, maximum distances?
The page tells you specifically to use rand()
yes but rand() in what context, like x=rand(), y=rand() and how do i make it nxn particles
What are the available syntaxes for rand() ?
rand(n), but when i put in as randomarray=rand(n), and ask for randomarray they give me an exact value
I am not sure what you mean by "an exact value" ?
If you mean that it gives specific numeric values, then Yes, that is what is required for the question. You are simulating numerically by generating particular numeric values and letting the equations act on the locations. The task at hand is not to do a mathematical modeling based upon statistics and calculus: it is to numerically model a system that has been randomly initialized.
yes but how do i determine the(x0, y0) coordinates for each particle using the rand() function. (when i enter that i get a precise number)
randomarrawy=rand(n)
randomarray=
0.8367
could you show me what the code would like please?
The word "determine" should be understood as "assign". Assign the (x0,y0) coordinates by using the rand() function to generate them.
The problem doesn't actually define what the geometry of the simulation shall be in terms of absolute geometric coordinates, only to make an NxN simulation; if you follow the instructions literally then the geometry will be on a [0,1) grid for x,y coordinates.
Normally, one has a given geometry of a region of space defined and then a grid is superimposed over that area such that there's a grid spacing in the x- and y-dimensions. Here they've left that portion out so just consider the overall dimensions of the area to be a 1x1 (m, say) square.

Sign in to comment.

Answers (1)

For instance, if you wanted to plot the results (red dots), you could use the rand function (i.e. help rand). First, define the limits of the simulation.
>> Lxmin=1; Lxmax=5; Lymin=2; Lymax=6; N = 100;
>> x = Lxmin+(Lxmax-Lxmin)*rand(N,1);
>> y = Lymin+(Lymax-Lymin)*rand(N,1);
>> plot(x,y,'.r','MarkerSize',12)
or just put the stuff in the plot command,
>> plot((Lymin+(Lymax-Lymin)*rand(N,1)),(Lymin+(Lymax-Lymin)*rand(N,1)),'.r','MarkerSize',12)

Categories

Tags

Asked:

on 29 Apr 2018

Edited:

dpb
on 29 Apr 2018

Community Treasure Hunt

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

Start Hunting!