How to generate random parking lot size?

2 views (last 30 days)
Thinh Hoang
Thinh Hoang on 7 Apr 2021
Commented: Walter Roberson on 7 Apr 2021
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?

Answers (1)

Walter Roberson
Walter Roberson on 7 Apr 2021
[randi([4 8]), randi([6 8])]
ans = 1×2
5 7
  2 Comments
Thinh Hoang
Thinh Hoang on 7 Apr 2021
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 on 7 Apr 2021
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
' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' ' !!! !!! !!!' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! ' '!!! !!! !!! '

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!