Borrar filtros
Borrar filtros

about rand and randi command

2 visualizaciones (últimos 30 días)
Oguzhan Sanliturk
Oguzhan Sanliturk el 15 de Mzo. de 2020
Comentada: Oguzhan Sanliturk el 15 de Mzo. de 2020
hi, i was wondering about how can i include number '0' in a randi command.
when i use it like 'randi(10)' it is always giving me numbers 1 to 10 but i need '0' also.
HELP please :D

Respuesta aceptada

Sriram Tadavarty
Sriram Tadavarty el 15 de Mzo. de 2020
Hi Oguzhan,
For the sample code, you can use this function signature
a = randi([0 10],1,1); % it will generate a random integer number from 0 (lower limit) to 10 (upper limit) of size 1 x 1
Here is the documentation link of randi, which provides more examples. https://www.mathworks.com/help/matlab/ref/randi.html
Hope this solves your issue.
Regards,
Sriram
  1 comentario
Oguzhan Sanliturk
Oguzhan Sanliturk el 15 de Mzo. de 2020
Totally understood! Thanks for your time Sriram!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by