How do I concatenate multiple vectors at random order?

3 次查看(过去 30 天)
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?

采纳的回答

KSSV
KSSV 2020-5-15
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)) ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by