MATLAB: Cannot vertically concatenate tables in for loop

for loopstructuretable

Hello experts,
I have an elementary, yet unsolvable issue for me. I checked other questions, I checked the material on the official site but I cannot solve my problem.
I have a 1×1 structure named "tbl" with 17 fields. Each field is a Nx5 table.
I would like to take each table and append that table to the previous one to obtain an Nx5 table, where N is the total number of rows from all the tables.
To append one to the other I know I can do this:
total = [tbl.ID2; tbl.ID4];
But I'd rather do it in a for loop, since I'll add further IDs and it's going to be quite time consuming.
resulting_tbl = table;
for id = tbl
resulting_tbl = [id;];
end
this code above is just creating the same initial structure instead of a new resulting table.
I know I'm missing some basic notions, but I cannot overtake this problem.
Thank you all for your time and help!
Marco

Best Answer

temp = struct2cell(tbl);
resulting_tbl = vertcat(temp{:});