Conversion of uitable Column Names to Table Column Names

11 visualizaciones (últimos 30 días)
Jason
Jason el 11 de Oct. de 2019
Respondida: Jalaj Gambhir el 14 de Oct. de 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

Respuestas (1)

Jalaj Gambhir
Jalaj Gambhir el 14 de Oct. de 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);

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by