How to randomly select an array of 20 nonrepeating values from another array which has 100 values with positive or negative values.
Show older comments
How to randomly select an array of 20 nonrepeating values from another array which has 100 values with positive or negative values inside.
Answers (2)
David Hill
on 4 Jun 2022
a=randi(200,1,100)-100;
SelectArray=a(randperm(100,20));
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!