How do I concatenate multiple vectors at random order?

3 views (last 30 days)
Hi All!
I'm generating trajectories for participants to follow in a study. They consist of different segments, that i have in vectors - 20-30 different ones, of different lengths.
Now I'd like to concatenate these vectors at a random order in order to generate different trajectories for each participant.
So if I've got
a=1:10;
b=2:12;
c=3:13;
I'd like to get a vecor [a, b, c] whereby the order of a, b and c are randomly chosen (so b, c, a; c, a, b; and so on)
Is there an easy solution for this?

Accepted Answer

KSSV
KSSV on 15 May 2020
Use them as cells and make the indices random.
a{1} = 1:10 ;
a{2} = 2:12 ;
a{3} = 3:13 ;
idx = randperm(3) ;
iwant = cell2mat(a(idx)) ;

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!