MATLAB: Randomly combine between 2 vector

combineMATLABmatrixrandomvector

Dear all, how i can combine randomly between 2 vector
V1 = [A B C]
V2 = [1 2 3]
to get for example (C,2), (A,3) and (B,1) As matrix
MV1V2 = C 2
A 3
B 1

Best Answer

To randomly "shuffle" the elements of a vector you can use randperm:
>> V1 = [10;20;30];
>> V2 = [ 1; 2; 3];
>> [V1(randperm(numel(V1))),V2(randperm(numel(V2)))]
ans =
20 3
10 2
30 1