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 Center および File ExchangeDevelop 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