Add data in a table according to the variable names.

1 回表示 (過去 30 日間)
Patricia Alejandra Palacios Romero
Patricia Alejandra Palacios Romero 2018 年 6 月 6 日
I have written a code with a for loop and at the end of each iteration the output is a table with the corresponding variable names, something like this:
head = {'level_RI1','inflow_RI1','outflow_RI1'}
B.Properties.VariableNames = head;
the second iteration output is a table like this:
head = {'level_R2','inflow_R2','outflow_R2'}
B.Properties.VariableNames = head;
at the end I want to merge the results of each iteration in a final table which variable names are:
Result.Properties.VariableNames = {'level_RI1','inflow_RI1','outflow_RI1','level_R2','inflow_R2','outflow_R2'}
But so far I just get the table to overwrite itself at the end of the iterations and the result just contain the final iteration:
Result.Properties.VariableNames = {'level_R2','inflow_R2','outflow_R2'}
I'd appreciate any help :)

採用された回答

Peter Perkins
Peter Perkins 2018 年 6 月 7 日
I can't tell if the question is about just the variable names, or the tables themselves. So this may be answering a different question than you asked.
If you have several tables with variable names that don't conflict, just horzcat them:
result = [T1, T2, T3]
Presumably you have many tables, so you can't really hard-code that line. If you store each individual table in a cell array at each iteration of your loop, you can expand that cell array to horzcat them:
for i = ...
myTables{i} = ...
end
result = [myTables{:}];
  1 件のコメント
Patricia Alejandra Palacios Romero
Patricia Alejandra Palacios Romero 2018 年 6 月 19 日
Thank you! that really helped. Regards.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by