필터 지우기
필터 지우기

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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by