MATLAB: How to generate say 100 points randomly in a square or rectangle

create a squarepoints generation

I want to generate 100 points in a square , which side length is 5 m.

Best Answer

x=rand(1,100)*5
y=rand(1,100)*5
scatter(x,y)
or
a=rand(2,100)*5
scatter(a(1,:),a(2,:))