generate random negative numbers
显示 更早的评论
I thank if some one can help in this, how can i generate a matrix of some size for ex 100x100 with in the range of [-0.01,0] and that too with decimal values contained in it like -0.001,-0.0056 like that and also for the ranges like [-60,-30] with decimal values like -58.254,-56.985 and only 3 decimal values after the point.
5 个评论
PK
2013-1-26
Evgeny Pr
2013-1-26
This is a learning task, or what?
Image Analyst
2013-1-26
The answer to this is the example to rand() in the help.
PK
2013-1-28
Image Analyst
2013-1-28
Sorry but you are wrong. Look at Greg's code below, which is the same as the help example I referred you to. You can certainly have "a" and "b" be negative numbers. Why do you think you can't? No one said they had to be positive.
采纳的回答
更多回答(1 个)
Greg Heath
2013-1-26
2 个投票
x = a + (b-a)*rand(m,n);
Hope this helps.
Thank you for formally accepting my answer.
Greg
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!