how can I choose random "n" matrices from array of matrices ?
13 views (last 30 days)
Show older comments
Dear all,
I have a problem and I hope somebody can help.
I have vector array of elements, the array contains matrices and I want to choose randomly "n" matrices from array
how can I choose ???
m1=[ 0 1; 0 0];
m2=[ 0 1; 0 1];
m3=[ 1 1; 0 0];
m4=[ 1 1; 0 1];
array=[m1 m2 m3 m4];
I hope I am clear enough.
Thanks in advance,
Ghaida
0 Comments
Answers (1)
Stephen23
on 26 Jan 2019
Edited: Stephen23
on 26 Jan 2019
If you followed the advice I gave in response to your last question:
https://www.mathworks.com/matlabcentral/answers/441492-how-to-get-the-first-position-in-the-array-and-get-size-array-contains-matrices#answer_358027
then this would be trivial:
N = number of matrices you want to get
idx = randi(numel(C),1,N);
C(idx)
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!