how to store the matrix in a single table after every iteration
2 ビュー (過去 30 日間)
古いコメントを表示
suppose i have a matrix which size is always same but value does not same it will be change after every iteration for i=1:2 matrix result after iteration 1
A B
1.21 21.32
21.32 32.21
89.11 32.87
matrix result after iteration 2
A B
21.32 43.21
43.54 78.32
77.23 99.1
end now i wish to add new matrix in the next column of table when new iteration will be run. all array values are in the table after iteration over.
A B A B
1.21 21.32 21.32 43.21
21.32 32.21 43.54 78.32
89.11 32.87 77.23 99.1
0 件のコメント
回答 (2 件)
Guillaume
2015 年 4 月 29 日
You can't have duplicate variable names (column headers) in a table, so your desired output is not possible.
If you use different column names, then joining two tables is trivial:
t1 = array2table([1.21 21.32; 21.32 32.21; 89.11 32.87], 'VariableNames', {'A1', 'B1'});
t2 = array2table([21.32 43.21; 43.54 78.32; 77.23 99.1], 'VariableNames', {'A2', 'B2'});
tmerged = [t1 t2]
You could generate the variable names for each loop with:
varnames = cellfun(@(prefix) sprintf('%s%d', prefix, i), {'A', 'B'}, 'UniformOutput', false);
I'm not sure it's a good idea, though. Why not concatenate the rows instead of the columns?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!