random number between -1 and 1

61 次查看(过去 30 天)
Hi I need a 1 line code for a random number generator between 1 and -1 for one element.

采纳的回答

Wayne King
Wayne King 2012-4-15
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 个评论
Jan
Jan 2012-4-15
@Mate 2u: If you read the help text of RAND you find corresponding examples. Please take the time to read the help and doc.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by