How can I make a random array with values of either -1 or 1?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Quinlin Hamill
el 24 de Oct. de 2016
Comentada: Quinlin Hamill
el 24 de Oct. de 2016
I'm trying to use randi to make a matrix filled with either -1 or 1 however randi also includes 0s.
0 comentarios
Respuesta aceptada
Image Analyst
el 24 de Oct. de 2016
Try this:
r = 2 * randi(2) - 3
I just answered this very recently.
Ver también
Categorías
Más información sobre Random Number Generation 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!