Generating random numbers in order?
显示 更早的评论
How would you generate random numbers so that they are in ascending or descending order? Is there a way to create a function similar to linspace in that it generates linearly spaced values in a certain interval but with random numbers each time you execute the function?
采纳的回答
更多回答(1 个)
NIKHIL KUMAR
2021-12-9
0 个投票
x = sort((10-1)*rand(n,1)+1,'ascend' or 'descend');
1 个评论
Walter Roberson
2021-12-9
This is the same as what Roger suggested in 2013.
类别
在 帮助中心 和 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!