random number between -1 and 1

Hi I need a 1 line code for a random number generator between 1 and -1 for one element.

 Respuesta aceptada

Wayne King
Wayne King el 15 de Abr. de 2012

3 votos

Do you want these uniform between -1 and 1?
r = -1 + 2.*rand(100,1);
For 1 such number
r = -1+2*rand(1,1);

1 comentario

Jan
Jan el 15 de Abr. de 2012
@Mate 2u: If you read the help text of RAND you find corresponding examples. Please take the time to read the help and doc.

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.

Etiquetas

Preguntada:

el 15 de Abr. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by