I am a Matlab novice. I am sorry that my question may be silly.
Does anyone know that how I can repeat each element of a vector different times and then store them in a new vector?
Thank you in advance for the answers
No products are associated with this question.
You can get this from the file exchange.
Wayne pointed you to a run-length decoder/encoder.
Things become more simple if every element is to be repeated the same number of times:
% repeat all elements of A N times A = [1 2 3] N = 3 ; B1 = reshape(repmat(A(:).',N,1),1,) % or nA = numel(A) ; B2 = A(ceil((1:nA*N)/nA))
Play games and win prizes!Learn more