Add 9 rows after every row in a table

2 views (last 30 days)
Fraje Watson
Fraje Watson on 28 Aug 2019
Commented: Fraje Watson on 28 Aug 2019
Hello, I have a (43400,39) table. For every row I'd like to enter 9 copies of that row beneath.
e.g.
1111
2222
turns into
1111
1111
1111
1111
1111
1111
1111
1111
1111
1111
2222
2222
etc.
I've attempted to use the 'insertrows' function shown here, but I'm not really competant enough to interpret it at all/for my needs https://uk.mathworks.com/matlabcentral/fileexchange/9984-insertrows
My script is currently as follows:
T = readtable('filename.xlsx', 'Sheet', 'RawData');
Many thanks, Fraje
  2 Comments
Johannes Fischer
Johannes Fischer on 28 Aug 2019
I'm pretty sure repelem does exactly what you are looking for.
Fraje Watson
Fraje Watson on 28 Aug 2019
Brilliant - that's perfect and simple enough for me to understand :)
T = readtable('filename.xlsx', 'Sheet', 'RawData');
T2 = repelem(T,10,1);

Sign in to comment.

Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!