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.
0 个评论
采纳的回答
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
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 Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!