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 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Guillaume
on 11 Jan 2018
I'm also unclear on the question.
"generates a string for every value": use compose:
compose("Column %d", 1:10)
More Answers (1)
Simon Parten
on 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...
0 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!