Add columns to tables with loops
    6 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Isai Fernandez
 le 19 Mai 2020
  
    
    
    
    
    Réponse apportée : Ameer Hamza
      
      
 le 19 Mai 2020
            I want to create a first column for my table, after a loop. I tried like this:
%N(mxn)
i=1;
while i<= size(N,1)
    capa(i) = fprintf('Bar #',int2str(i));
    i=i+1;
end
Furthermore I used sprintf.
The result in this case of three rows, it would be:
Bar 1
Bar 2
Bar 3

0 commentaires
Réponse acceptée
  Ameer Hamza
      
      
 le 19 Mai 2020
        See this example
t = array2table(rand(3)); % example table
rows = compose('Bar %d', [1 2 3]);
rows = vertcat(rows{:});
T = [table(rows, 'VariableNames', {'labels'}) t];
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Tables 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!

