MATLAB: How to generate a vector of two separate intervals without overlapping

random permutationtwo intervals

Assume that we have two vectors:
a = 1 2 3 4 5
b= 6 7 8 9 10
how can I generate a vector of random permutation of combining a and b so I can always get random permutation of a at first and then random permutation of b in vector c as below:
c = 1 2 3 4 5 6 7 8 9 10
or
c = 5 1 3 4 2 9 7 6 10 8

Best Answer

c = [a(randperm(length(a))) b(randperm(length(b)))]