How to randomly select an array of 20 nonrepeating values from another array which has 100 values with positive or negative values.

1 view (last 30 days)
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
David Hill on 4 Jun 2022
a=randi(200,1,100)-100;
SelectArray=a(randperm(100,20));

Md Nazmul Hoque
Md Nazmul Hoque on 4 Jun 2022
like lets say,
its a 3*20 matrix i want to generate, from 3*100 matrix,
i want to select 20 random column, but that 20 random column's corrospending row should not be changed.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!