How to generate repeat column labels
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aaron Ouyang
el 21 de Mayo de 2022
Respondida: Walter Roberson
el 21 de Mayo de 2022
Hi
I'm looking to create column labels for my table:
array2table(data,'VariableNames',{'FirstName' 'Height' 'Weight' 'BloodPressure'})
I want the variable names to be Cell 1, Cell 2, Cell 3, Cell 4, etc. until Cell 100. How can I generate these repeat character strings without typing it out manually? Thanks.
0 comentarios
Respuesta aceptada
Walter Roberson
el 21 de Mayo de 2022
array2table(data,'variablenames', "Cell" + (1:100))
0 comentarios
Más respuestas (1)
Atsushi Ueno
el 21 de Mayo de 2022
text = sprintf('Cell %d\n',1:100);
text(end) = []; % to avoid an empty cell at the end
labels = splitlines(text);
array2table(1:100,'VariableNames',labels)
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!