Conversion of uitable Column Names to Table Column Names

조회 수: 12 (최근 30일)
Jason
Jason 2019년 10월 11일
답변: Jalaj Gambhir 2019년 10월 14일
Hi, I have a uitable (containing doubles) that I am writing to an excel file by first converting it to a table, then using WriteTable.
I want to include the uitable column names.
My column names are like this:
cnames =
7×1 cell array
{'X' }
{'Y' }
{'Z' }
{'FM' }
{'diff' }
{'dy1' }
{'dy2' }
I see that in the conversion from array to Table, there is a field for variable names, however it is in this form:
T = array2table(A,...
'VariableNames',{'Feet','Inches','Centimeters'})
I know I can transpose my uitable cnames to give
cnames =
1×17 cell array
{'X'} {'Y'} {'Z'} {'FM'} {'diff'} {'dy1'} {'dy2'}
But Im not sure how to get in the format required for the table.
Thanks
  댓글 수: 1
Jason
Jason 2019년 10월 13일
Seems like it doesn't like column headings like '<circ>'

댓글을 달려면 로그인하십시오.

답변 (1개)

Jalaj Gambhir
Jalaj Gambhir 2019년 10월 14일
Hi,
You can directly use the transposed cnames as Variable names. As in,
cnames = {'X';'Y';'Z';'FM';'diff';'dy1';'dy2'};
row = cnames';
A = rand(20,7);
B = array2table(A,'VariableNames',row);

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by