randomly selecting an element without randsample

5 vues (au cours des 30 derniers jours)
cgo
cgo le 23 Avr 2021
How do I randomly select an element without the machine learning toolbox function randsample?

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Avr 2021
YourData(randi(numel(YourData), SIZE)) %select SIZE elements WITH REPETITION
YourData(randperm(numel(YourData), NUMBER)) %select NUMBER elements WITHOUT REPETITION
SIZE can be a vector of values such as [5 7] to generate a 5 x 7 matrix with repetition.
NUMBER must be a positive integer scalar; reshape() afterwards if you need to.

Plus de réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by