generating random numbers only 2 numbers

5 views (last 30 days)
i want to generating random numbers on matrix 1x30
how i get generating 2 random numbers (only 1 and 4 , not between) ???

Accepted Answer

Chunru
Chunru on 17 Sep 2021
Edited: Chunru on 17 Sep 2021
a = randi([0 1], [1 30])*3 + 1
a = 1×30
1 1 4 4 4 4 4 1 1 4 1 4 4 4 1 4 4 4 1 1 1 4 1 4 4 1 4 4 4 4

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!