syntax for random number
Ältere Kommentare anzeigen
i need a syntax that generate one number in random from a range of numbers.
Can anyone tell me the syntax,
this is a python function random.randrange(50, 500, 10) i need the function which works in matlab
Antworten (4)
a = 50;
b = 500;
r = (b-a).*rand(10,1) + a;
madhan ravi
am 8 Apr. 2019
0 Stimmen
https://in.mathworks.com/help/matlab/ref/rand.html - see under Topics , you will find lot of resources
Varsha Nataraj
am 10 Apr. 2019
0 Stimmen
Steven Lord
am 10 Apr. 2019
0 Stimmen
Take a look at the randi or randperm functions.
If you need to generate numbers from a set that contains non-integer values, or a set that is not consecutive integers, use those functions to generate an index and use linear indexing to extract the appropriate numbers from the set.
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!