One of the way can be to find a rectangle enclosing all the vertices, create uniformly distributed random points inside the rectangle and then filter out the points using inpolygon()
x = [2 2 3 4];
y = [1 3 2 5];
X = [x.' y.'];
idx = convhull(X);
X = X(idx, :);
ll_corner = [min(x) min(y)];
tr_corner = [max(x) max(y)];
points = rescale(rand(10000, 2), ll_corner, tr_corner);
idx = inpolygon(points(:,1), points(:,2), X(:,1), X(:,2));
points = points(idx, :);
figure();
ax = axes();
plot(X(:,1), X(:,2), 'LineWidth', 1)
hold on
plot(points(:,1), points(:,2), '.')
Best Answer