i have the following array

1 vue (au cours des 30 derniers jours)
mohammed elmenshawy
mohammed elmenshawy le 12 Juil 2017
Commenté : Star Strider le 13 Juil 2017
Z=[22,45,65,35,65,54,45,67,84,95,86,58,29,95,93]; How to choose 5 random numbers from these numbers?? So that the output is within these numbers??

Réponse acceptée

Star Strider
Star Strider le 12 Juil 2017
One approach:
Z=[22,45,65,35,65,54,45,67,84,95,86,58,29,95,93];
Out = Z(randperm(numel(Z),5))
The randperm function will create random indices for 5 elements of ‘Z’ without repetition.
  2 commentaires
mohammed elmenshawy
mohammed elmenshawy le 13 Juil 2017
thank u very much
Star Strider
Star Strider le 13 Juil 2017
My pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by