Conversion of uitable Column Names to Table Column Names

12 Ansichten (letzte 30 Tage)
Jason
Jason am 11 Okt. 2019
Beantwortet: Jalaj Gambhir am 14 Okt. 2019
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

Antworten (1)

Jalaj Gambhir
Jalaj Gambhir am 14 Okt. 2019
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);

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by