generating random numbers only 2 numbers

8 visualizzazioni (ultimi 30 giorni)
i want to generating random numbers on matrix 1x30
how i get generating 2 random numbers (only 1 and 4 , not between) ???

Risposta accettata

Chunru
Chunru il 17 Set 2021
Modificato: Chunru il 17 Set 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

Più risposte (0)

Categorie

Scopri di più su Random Number Generation in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by