I have two matrices of size 100 x 1
A=[a1;a2;a3;...;a100]
N=[n1;n2;n3;...;n100]
I want to create a matrix of size sum(N) x 1 that has a1 elements of n1, a2 elements of n2 and ...:
How can I do this in MATLAB?
You can use repelem to repeat each element in A by the corresponding entry in N
A = [1, 2, 3];
N = [3, 2, 1];
output = repelem(A, N);
% 1 1 1 2 2 3