How do I create column names?

조회 수: 5 (최근 30일)
Cathy
Cathy 2013년 8월 1일
I have a 1x49 cell array (header_file) that contains the column names of a 1998x49 double data array (data_file). How do I make the 49 values in the header_file be the 49 column names in the data_file?

채택된 답변

John Petersen
John Petersen 2013년 8월 1일
편집: John Petersen 2013년 8월 1일
Can you use a structure instead with fieldnames of the column names?
1. Read the names in as strings.
2. Read the data into an array.
3. Use setfield to assign fieldnames to the structure and set the value to the appropriate column of the array.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 8월 1일
Numeric arrays cannot have non-numeric headers.
The closest you can get is to create a cell array:
newcell = [header_file; num2cell(data_file)];

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by