MATLAB: Create a vector by selection randomly vectors

vectors

Hi all,
I have 4 vectors
A=[1 2 3 4 5];
B=[0 2 5 6 19];
C=[0 0 1 3 0];
D=[1 0 1 15 0];
And I want to create vectors by randomly selecting from the list above, so that I take something like:
Vector1=[B;C;D;A]
Vector2=[C;D;A;B]
Vector3=[A;D;C;B]
.
.
.
etc.

Best Answer

A=[1 2 3 4 5];
B=[0 2 5 6 19];
C=[0 0 1 3 0];
D=[1 0 1 15 0];
pool = [A; B; C; D];
n = 10 % Number of vectors to create
for k = 1:n
idx = randperm(4);
result(k,:) = [pool(idx(1),:), pool(idx(2),:), pool(idx(3),:), pool(idx(4),:)]
end
This code stores the created vectors in the lines of a Matrix. Access them with:
vector_1 = result(1,:)
vector_2 = result(2,:)
.
.
.
vector_n = result(n,:)
Best regards
Stephan