How to randomly select an array of 20 nonrepeating values from another array which has 100 values with positive or negative values.
Ältere Kommentare anzeigen
How to randomly select an array of 20 nonrepeating values from another array which has 100 values with positive or negative values inside.
Antworten (2)
David Hill
am 4 Jun. 2022
a=randi(200,1,100)-100;
SelectArray=a(randperm(100,20));
Md Nazmul Hoque
am 4 Jun. 2022
0 Stimmen
1 Kommentar
N = randperm(100);
N = sort(N(1:20));
a = a(:,N);
Kategorien
Mehr zu Random Number Generation 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!