random Distribution Points inside rectangle
Show older comments
hi every one how can i distribute randomly a number of points inside rectangle and every point has x,y ex: px(1)=100; py(1)=-100; and so forth where the rectangle code as shown bellow:-
x=-1100;
y=-1100;
rectangle('position',[x,y,2200,2200],'LineWidth',2,'LineStyle','--');
Accepted Answer
More Answers (1)
Bjorn Gustavsson
on 5 Feb 2017
1 vote
Have a look at the documentation of rand. That function gives you uniformly distributed random numbers between 0 and 1 (have forgotten about what the limits are, but you'll see). Then think about what happens if you add and multiply those numbers with some fixed constants, then think about what happens if you combine 2 such numbers into a 2-d vector. If you want some other distribution of the points inside your rectangle or want the points to have some covariance structure you'll have to work those out as well.
HTH
Categories
Find more on Exploration and Visualization 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!