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

5 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by