MATLAB: How i can generate random points inside a cube

cuberandom points

i want to generate rondom points inside a cube.

Best Answer

You can use rand()
Z = rand(10,10,10);
The above gives you the unit cube. You can translate this and scale the side length:
Z = 2+(4-2)*rand(10,10,10);