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

1 vue (au cours des 30 derniers jours)
How to randomly select an array of 20 nonrepeating values from another array which has 100 values with positive or negative values inside.

Réponses (2)

David Hill
David Hill le 4 Juin 2022
a=randi(200,1,100)-100;
SelectArray=a(randperm(100,20));

Md Nazmul Hoque
Md Nazmul Hoque le 4 Juin 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.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by