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

조회 수: 1 (최근 30일)
Murtada Mohamed
Murtada Mohamed 2019년 12월 21일
댓글: Murtada Mohamed 2019년 12월 21일
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?

채택된 답변

Stephen23
Stephen23 2019년 12월 21일
편집: Stephen23 2019년 12월 21일
>> 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by