我想重复一个数组的每个值特定的次数,确切的数字可以在另一个数组中找到。我想要一种不涉及循环的系统方法。
a = [1,2,3]; % the values I want to repeat
b = [3,4,2]; % the number of times they should be repeated
% the outcome I want
c = [repmat(a(1),1,b(1)),repmat(a(2),1,b(2)),repmat(a(3),1,b(3))]
我觉得这个问题一定已经在这里的某个地方回答了,但是我找到的所有答案都是关于Python的。