how can I choose random "n" matrices from array of matrices ?

13 views (last 30 days)
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

Answers (1)

Stephen23
Stephen23 on 26 Jan 2019
Edited: Stephen23 on 26 Jan 2019
If you followed the advice I gave in response to your last question:
then this would be trivial:
N = number of matrices you want to get
idx = randi(numel(C),1,N);
C(idx)

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!