how to store the matrix in a single table after every iteration
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Guillaume
le 29 Avr 2015
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 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!