Generating random numbers in order?
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (1)
NIKHIL KUMAR
am 9 Dez. 2021
0 Stimmen
x = sort((10-1)*rand(n,1)+1,'ascend' or 'descend');
1 Kommentar
Walter Roberson
am 9 Dez. 2021
This is the same as what Roger suggested in 2013.
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!