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 回表示 (過去 30 日間)
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"

採用された回答

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

その他の回答 (1 件)

Simon Parten
Simon Parten 2018 年 1 月 11 日
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...

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by