How to repeat rows of a matrix sequentially?

조회 수: 2 (최근 30일)
Parth Sarathi
Parth Sarathi 2016년 5월 3일
답변: Guillaume 2016년 5월 3일
I have a column with 24 rows as attached in the file 'DATA.xlsx'. I want each row to repeat 20 times one after the other i.e.first and second element in the given column is 23, 45 and so on. The new column should contain 20 rows of 23 then 20 rows of 45 and so on keep repeating. How can this be done? Thanks and regards, Parth

답변 (2개)

Roger Stafford
Roger Stafford 2016년 5월 3일
Let your present 24 x 1 column vector be called x.
x2 = reshape(repmat(x.,20,1),[],1);

Guillaume
Guillaume 2016년 5월 3일
A simpler method than Roger's
x2 = repelem(x, 20)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by