how can i place NxN particles randomly on a two dimensional plane?
Show older comments
how can i place NxN particles randomly on a two dimensional plane? http://www.chegg.com/homework-help/questions-and-answers/task-2-write-matlab-function-script-implement-scheme-page-11-40-points-page-11-step-step-i-q28743242 (please help)
11 Comments
Walter Roberson
on 29 Apr 2018
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?
Justin Hendriks
on 29 Apr 2018
Edited: Justin Hendriks
on 29 Apr 2018
Walter Roberson
on 29 Apr 2018
The page tells you specifically to use rand()
Justin Hendriks
on 29 Apr 2018
Walter Roberson
on 29 Apr 2018
What are the available syntaxes for rand() ?
Justin Hendriks
on 29 Apr 2018
Walter Roberson
on 29 Apr 2018
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.
Justin Hendriks
on 29 Apr 2018
Justin Hendriks
on 29 Apr 2018
Walter Roberson
on 29 Apr 2018
The word "determine" should be understood as "assign". Assign the (x0,y0) coordinates by using the rand() function to generate them.
dpb
on 29 Apr 2018
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.
Answers (1)
phillip stallworth
on 29 Apr 2018
Edited: dpb
on 29 Apr 2018
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
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!