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?
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!