You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
This tool allows a user to generate randomly (uniformly) distributed points inside a polygonal region, so any simple region in the (x,y) plane you can describe with a polygon, or a polyshape.
PS = polyshape([0 0;1 0;1 1;.6 .3])
xy = randpoly(100,PS);
plot(xy(:,1),xy(:,2),'ro')
hold on
plot(PS)
The scheme used is a constructive one that is uniformly distributed in the given 2-dimensional domain. It is NOT a rejection scheme, as they can be extremely wasteful of CPU time.
Cite As
John D'Errico (2026). randpoly (https://www.mathworks.com/matlabcentral/fileexchange/125580-randpoly), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.1 (2.36 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
