How to select random numbers from array for creating new matrix?

I have b1 array. b1=[-3,-1,1,3,5];
I want to create 3x4 matrix by using random elements of b1 array.
So, one of expected outputs:
ans= -1 5 -3 1
1 -3 5 -3
3 5 1 3
Anyone can help?

 採用された回答

Stephan
Stephan 2018 年 12 月 11 日
編集済み: Stephan 2018 年 12 月 11 日

2 投票

Hi,
try:
b1=[-3,-1,1,3,5];
A = b1(randi(numel(b1),3,4))
possible result:
A =
1 -1 -3 3
-3 5 -3 3
-1 -3 3 1
Best regards
Stephan

2 件のコメント

madhan ravi
madhan ravi 2018 年 12 月 11 日
+1
Azad Asadov
Azad Asadov 2018 年 12 月 11 日
thanks a lot.

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2018 年 12 月 11 日

コメント済み:

2018 年 12 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by