Create delimited random vertices
조회 수: 2 (최근 30일)
이전 댓글 표시
I need to randomly generate 5 points delimited in (0< X< 50) and ( 0< Y< 50)and automatically arrange these in increasing value
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 11월 27일
You can sort the randomly generated values
x = sort(randi([1 49], 5, 1));
y = sort(randi([1 49], 5, 1));
댓글 수: 7
Ameer Hamza
2020년 11월 27일
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))
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!