inefficient loop to vertically concatenate tables

10 ビュー (過去 30 日間)
Daniel Pinto
Daniel Pinto 2019 年 8 月 8 日
コメント済み: Daniel Pinto 2019 年 8 月 8 日
I have a 300000 by 2 table, called output, that looks like in the screenshot below. Each entry in the 2nd column as inside it a 3-column table with different numbers of rows. I woud like to havee one single table with 3-columns, that is, vertically merge all those little 3-column tables into one.
So far, I was doing:
tableBig = array2table([]);
for ii = 1 : size(output,1)
temp = output{ii,2};
temp = temp{:};
tableBig = [tableBig; temp];
The problem is that this loop is a inefficient time wise. The first iterations take in the order of 0.0025 seconds which is not too too bad. But as tableBig gets bigger, iterations seem to take longer and longer, so that projected time based on tic/toc is more than 24 hours.
Is there a way to do this without a loop or to speed up the loop?
Screenshot 2019-08-08 at 11.15.26.png


Jos (10584)
Jos (10584) 2019 年 8 月 8 日
You can apply comma-separated list expansion to tables too, so this one-liner should work.
tableBig = cat(1, output{:,2})
  5 件のコメント
Daniel Pinto
Daniel Pinto 2019 年 8 月 8 日
thanks a lot! that works.
my code is still not working properly, so I have added the full description of my problem and my goal here:
If you have time, please read it! thanks!


その他の回答 (0 件)


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!

Translated by