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??

 採用された回答

Star Strider
Star Strider 2017 年 7 月 12 日

0 投票

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 件のコメント

mohammed elmenshawy
mohammed elmenshawy 2017 年 7 月 13 日
thank u very much
Star Strider
Star Strider 2017 年 7 月 13 日
My pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Random Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by