MATLAB Answers

Create delimited random vertices

1 view (last 30 days)
Sawera Zahra
Sawera Zahra on 27 Nov 2020
Commented: Ameer Hamza on 27 Nov 2020
I need to randomly generate 5 points delimited in (0< X< 50) and ( 0< Y< 50)and automatically arrange these in increasing value

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 27 Nov 2020
You can sort the randomly generated values
x = sort(randi([1 49], 5, 1));
y = sort(randi([1 49], 5, 1));

  7 Comments

Show 4 older comments
Sawera Zahra
Sawera Zahra on 27 Nov 2020
This seems to be closer to the problem' s solution but starting point and ending points should be P0,0 and P 4, 0 respectively
Sawera Zahra
Sawera Zahra on 27 Nov 2020
Within above x, y, z limits*
Ameer Hamza
Ameer Hamza on 27 Nov 2020
You can use rescale in that case
x_lims = [0 50];
y_lims = [0 50];
z_lims = [50 50];
n = 5;
x = rescale(sort(rand(n,1)), x_lims(1), x_lims(2))
y = rescale(sort(rand(n,1)), y_lims(1), y_lims(2))
z = rescale(sort(rand(n,1)), z_lims(1), z_lims(2))

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by