Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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"

Réponse acceptée

Guillaume
Guillaume le 11 Jan 2018
I'm also unclear on the question.
"generates a string for every value": use compose:
compose("Column %d", 1:10)

Plus de réponses (1)

Simon Parten
Simon Parten le 11 Jan 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...

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!

Translated by