align the random number in straight line that will restrict in the box dimension
Show older comments
N=40;
phi=0.6;
% Dimension of the box
L=15;
% Diameter of particles
d=sqrt(4*phi*L^2/(pi*N));
a=d/2;
% Perturbation
epsilon=[0.0001];
for run=1:1
for i=1:N
% place particle i randomly
% x position will be randomly from -7.5 to 7.5
X0in(2*i-1)=L*(rand(1)-1/2);
% y position will be randomly from -7.5 to 7.5
X0in(2*i)=L*(rand(1)-1/2);
end
end
I want to generate 40 different positions in the square box from -7.5 to 7.5 for both x and y direction. Because it has higher area fraction with larger number of position (40), hence it is so hard for Matlab to give me the result without overlapping. I want to generate and put them in a straight line order from -7.5 to 7.5 then move a little bit if they overlap. But I dont know how to put the random number that aligns in the straight line in this box ( dont matter if they overlap or not). Note: I will draw circle for each X-Y position with diameter d.
Any helps would be nice. Thanks
1 Comment
Walter Roberson
on 8 Mar 2013
A straight line along which axis? Are you referring to sort() ?
Question: why are you not using
X0in = L * (rand(2*N) - 1/2);
Accepted Answer
More Answers (0)
Categories
Find more on Probability Distributions and Hypothesis Tests 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!