How to generate a random set of x,y coordinates
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am working on a particle tracking project and I need to generate a random set of (x,z) pairs that indacte the particle release location. The coordinates need to be restricted to a box with a xmin,xmax and zmin,zmax. Here is what I have so far.
xmax = 0.4;
xmin = 0.2;
zmin = 0.2;
zmax = 0.32;
xrand = rand(1,400);
xinit = xmin + xrand*(xmax - xmin));
zrand = rand(1,400);
zinit = zmin + zrand*(zmax - zmin));
P.xp(:,1) = xinit(p);%these are the variables the coordinates will be stored in
P.zp(:,1) = zinit(p);
0 Kommentare
Antworten (1)
Torsten
am 27 Okt. 2022
xmax = 0.4;
xmin = 0.2;
zmin = 0.2;
zmax = 0.32;
xrand = rand(1,400);
xinit = xmin + xrand*(xmax - xmin);
zrand = rand(1,400);
zinit = zmin + zrand*(zmax - zmin);
P.xp(:,1) = xinit;%these are the variables the coordinates will be stored in
P.zp(:,1) = zinit;
2 Kommentare
Torsten
am 27 Okt. 2022
Original:
xinit = xmin + xrand*(xmax - xmin));
zinit = zmin + zrand*(zmax - zmin));
P.xp(:,1) = xinit(p);%these are the variables the coordinates will be stored in
P.zp(:,1) = zinit(p);
Modified:
xinit = xmin + xrand*(xmax - xmin);
zinit = zmin + zrand*(zmax - zmin);
P.xp(:,1) = xinit;%these are the variables the coordinates will be stored in
P.zp(:,1) = zinit;
Found the glasses ?
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!