how to find random number between 20 input numbers
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Maryam Abdirad
am 19 Nov. 2017
Beantwortet: Walter Roberson
am 19 Nov. 2017
I have 20 numbers that I want to find 1 or 2 or 3 of them as random. Could you help me to write code or any function that generate random number?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 19 Nov. 2017
L = length(YourVectorOfNumbers);
num_to_pick = randi(3);
which_to_pick = randperm(L, num_to_pick);
picked_values = YourVectorOfNumbers(which_to_pick);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!