Clear Filters
Clear Filters

i have the following array

3 views (last 30 days)
mohammed elmenshawy
mohammed elmenshawy on 12 Jul 2017
Commented: Star Strider on 13 Jul 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??

Accepted Answer

Star Strider
Star Strider on 12 Jul 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.

More Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!