is there a way to make a loop that reads the number of columns in a row and generates a string for every value read. For example
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Matt Brianik
el 11 de En. de 2018
Comentada: Matt Brianik
el 11 de En. de 2018
Is there a way to make a loop that reads the number of columns in a row and generates a string for every value read. For example I am reading in files between 5-50 columns of data. depending on the number of columns i want to make a label designation for example:
Headers= "1,2,3,4,5"
Headers_Split = strsplit(Headers,',')
therefore I'll have these labels to use when i export to excel. is there a way to automate this so that the "Headers" String automatically populates with the correct number of place holders? Also, would I be able to make it so that if columns "1,2,3,17,19" are read in, would the specific names of these files be maintained throughout the process so that the end product is not "1" "2" "3" "4" "5" but instead is "1" "2" "3" "17" "19"
0 comentarios
Respuesta aceptada
Guillaume
el 11 de En. de 2018
I'm also unclear on the question.
"generates a string for every value": use compose:
compose("Column %d", 1:10)
Más respuestas (1)
Simon Parten
el 11 de En. de 2018
Not sure if I've understood correctly, but 'readtable' would read an individual table.
You can figure out table width using 'width'. Then set headers of the columns of the table as you like using table.Properties.VariableNames...
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!