generating random numbers only 2 numbers

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

 Respuesta aceptada

Chunru
Chunru el 17 de Sept. de 2021
Editada: Chunru el 17 de Sept. de 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

2 comentarios

Takim Mustakim
Takim Mustakim el 17 de Sept. de 2021
ohhhh thank you bro/sist
Chunru
Chunru el 17 de Sept. de 2021
Consider to accept the answer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Preguntada:

el 17 de Sept. de 2021

Comentada:

el 17 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by