Conversion of uitable Column Names to Table Column Names

12 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Jalaj Gambhir
Jalaj Gambhir il 14 Ott 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);

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by