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

5 ビュー (過去 30 日間)
Azad Asadov
Azad Asadov 2018 年 12 月 11 日
コメント済み: Azad Asadov 2018 年 12 月 11 日
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 日
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 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by