Hello I am currently working on a bit of a project where I need to be able to create random points inside of an already created polygon that does not have known set boundaries. For my code provided below I am using the state of Washington that does not have any set boundaries for me to generate my points from. If I could get some proper guidance on the steps to take that would be wonderful. Thank you!
states = shaperead('usastatehi.shp'); wa = p(45); %creates a polgon in the shape of Washington State
numPointsIn = 20; for i = 1:numPointsIn flagIsIn = 0; while ~flagIsIn x(i) = rand(1); y(i) = rand(1); flagIsIn = polyshape(wa); end end plot(wa,'r+')
Best Answer