Borrar filtros
Borrar filtros

How to generate repeat column labels

4 visualizaciones (últimos 30 días)
Aaron Ouyang
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Mayo de 2022
array2table(data,'variablenames', "Cell" + (1:100))

Más respuestas (1)

Atsushi Ueno
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)
ans = 1×100 table
Cell 1 Cell 2 Cell 3 Cell 4 Cell 5 Cell 6 Cell 7 Cell 8 Cell 9 Cell 10 Cell 11 Cell 12 Cell 13 Cell 14 Cell 15 Cell 16 Cell 17 Cell 18 Cell 19 Cell 20 Cell 21 Cell 22 Cell 23 Cell 24 Cell 25 Cell 26 Cell 27 Cell 28 Cell 29 Cell 30 Cell 31 Cell 32 Cell 33 Cell 34 Cell 35 Cell 36 Cell 37 Cell 38 Cell 39 Cell 40 Cell 41 Cell 42 Cell 43 Cell 44 Cell 45 Cell 46 Cell 47 Cell 48 Cell 49 Cell 50 Cell 51 Cell 52 Cell 53 Cell 54 Cell 55 Cell 56 Cell 57 Cell 58 Cell 59 Cell 60 Cell 61 Cell 62 Cell 63 Cell 64 Cell 65 Cell 66 Cell 67 Cell 68 Cell 69 Cell 70 Cell 71 Cell 72 Cell 73 Cell 74 Cell 75 Cell 76 Cell 77 Cell 78 Cell 79 Cell 80 Cell 81 Cell 82 Cell 83 Cell 84 Cell 85 Cell 86 Cell 87 Cell 88 Cell 89 Cell 90 Cell 91 Cell 92 Cell 93 Cell 94 Cell 95 Cell 96 Cell 97 Cell 98 Cell 99 Cell 100 ______ ______ ______ ______ ______ ______ ______ ______ ______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ _______ ________ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by