MATLAB Answers

How can I repeat the values of an array in the same order?

1 view (last 30 days)
Hello
have an array
W = [ 1 2 3 4 5 ];
I would like it so that I can have a one dimensional array that repeats these falues in the same order an 'n' number of times.
so if i wanted it repeated 3 times my output would be as follows:
W2 = [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 ];
What is the easiest way to acomplish this?

  0 Comments

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 21 Dec 2019
Edited: Stephen Cobeldick on 21 Dec 2019
>> W = [1,2,3,4,5];
>> W2 = repmat(W,1,3)
W2 =
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

More Answers (0)

Sign in to answer this question.

Products


Release

R2016a