Borrar filtros
Borrar filtros

column vector with specified number

1 visualización (últimos 30 días)
yuval ohayon
yuval ohayon el 18 de Oct. de 2017
Respondida: Walter Roberson el 18 de Oct. de 2017
hi everyone, i need to generate column vector of 10 elements with only the number 2 and 3 ,it need to indexed randomly. well i have tried rand-rem, rbinom (x,y,z) is not working in my matlab, how I define only the numbers 2 and 3
solution a=[2 3 2 2 3 3 3 2 2 2 ] randomly
thanks

Respuestas (2)

Jan
Jan el 18 de Oct. de 2017
a = randi([2,3], 1, 10)

Walter Roberson
Walter Roberson el 18 de Oct. de 2017
a = randi([2 3], 1, 10);
"rbinom (x,y,z) is not working in my matlab"
rbinom is part of the R language, not part of MATLAB.

Categorías

Más información sobre MATLAB Compiler en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by