MATLAB: Tell me the code for how to place scatterrers in a cylindrical volume

creation of cylinder

place different scatterrers in a cylindrical volume

Best Answer

radius = 5;
height = 18;
N = 1000;
r = sqrt(rand(1,N)) * radius;
th = rand(1,N) * 2 * pi;
h = rand(1,N) * height;
[X, Y, Z] = pol2cart(th, r, h);
scatter3(X, Y, Z)
Related Question