Select random numbers form matrix

Can anyone help me, how can I choose 4 elelemts randomly from below matrix with and without repetaion.
P = ['a', 'b', 'c', 'd', '1', '2', '3', '4,']
Thanks in advance

 採用された回答

Matt J
Matt J 2021 年 3 月 25 日

0 投票

With repetition: Use randi()
Without repetition: Use randperm()

3 件のコメント

Matt J
Matt J 2021 年 3 月 25 日
k khaja's comment moved here
Thanks a lot, it works well.
Matt J
Matt J 2021 年 3 月 25 日
You're welcome, but please Accept-click the answer to indicate that your problem is resolved.
k khaja
k khaja 2021 年 3 月 29 日
Thanks a lot Matt, it works.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2021 年 3 月 25 日

コメント済み:

2021 年 3 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by