generate random size sphere which are randomly located inside a cylinder.

4 views (last 30 days)
i want to generate the random size shpere which are randomly located inside a cylinder. distribution follow the gaussian distribution for both location and radius of sphere. Any one please help me on this problem?

Answers (2)

Walter Roberson
Walter Roberson on 11 Aug 2021
You might need to adjust the details of the generation to be gaussian.
  21 Comments
Walter Roberson
Walter Roberson on 22 Aug 2021
Where Image Analyst coded
existing_z = zeros(1, numberWanted);
after that add
existing_R = zeros(1, numberWanted);
Then where he had
existing_z(numberPlaced) = XYZR(k, 3);
add after that
existing_R(numberPlaced) = XYZR(k, 4);
and where he coded
existing_z = existing_z(1 : numberPlaced);
add after that
existing_R = existing_R(1 : numberPlaced);
Now to calculate volume fraction, take
total_occupied_volume = sum(4/3*pi*existing_R.^3);
and referring back to the variables that were already defined that looked like
CylRadius = 40; CylHeight = 100;
then
total_cyl_volume = pi .* CylRadius.^2 .* CylHeight;
and now you can calculate the volume fraction.
If you need to calculate the volume fraction as you go, then you can keep a running total of the cube of existing_R() that has been assigned so far, after which the occupied volume is 4/3*pi times that sum of cubes.
Walter Roberson
Walter Roberson on 22 Aug 2021
can you please put here whole code?
He is not likely to do that. It is your assignment, and he already gave you links to places where people have posted sphere packing code, and he already gave you very solid outline of ensuring there are no overlaps and keeping the entries that are ok. He has done more than his share of your assignment.
If you post your code, with error, then one of the volunteers might explain to you why you got the error, but we are waiting for you to put in visible effort, so we are probably not going to fix the code for you, just tell you the cause of the error.

Sign in to comment.


Image Analyst
Image Analyst on 14 Aug 2021
Click on the tag links on the right for sphere packing and circle packing.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!