How to generate random parking lot size?

조회 수: 1 (최근 30일)
Thinh Hoang
Thinh Hoang 2021년 4월 7일
댓글: Walter Roberson 2021년 4월 7일
Hi,
I want to create a parking lot by plotting with random number of lots depending on its dimensions (each lot is 6m x 3m) and the min value is 4 rows x 6 columns to 8 rows and 8 columns. Can anyone help me?

답변 (1개)

Walter Roberson
Walter Roberson 2021년 4월 7일
[randi([4 8]), randi([6 8])]
ans = 1×2
5 7
  댓글 수: 2
Thinh Hoang
Thinh Hoang 2021년 4월 7일
Thank you very much, can you also help me on how to make each lot with 6x3 with that number of randomized rows and columns?
Thanks again.
Walter Roberson
Walter Roberson 2021년 4월 7일
format long g
r = randi([4 8])
r =
4
c = randi([6 8])
c =
6
d = char(logical(repelem(checkerboard(3, r, c),2,1)) + ' ');
e = d(1:end/2, 1:end/2)
e = 24×18 char array
' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! '

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by