writetable for a double entry table

19 visualizaciones (últimos 30 días)
Sim
Sim el 18 de Oct. de 2022
Respondida: Kevin Holly el 18 de Oct. de 2022
When I write a table with a double entry as a csv file....
labels_1 = {'FirstName' 'Height' 'Weight' 'BloodPressure'}
labels_1 = 1×4 cell array
{'FirstName'} {'Height'} {'Weight'} {'BloodPressure'}
labels_2 = {'Garcia' 'Johnson' 'Wu'}
labels_2 = 1×3 cell array
{'Garcia'} {'Johnson'} {'Wu'}
B = table({'Michael';'Beverly';'Alice'},...
[64;69;67],...
[119;163;133],...
[122 80; 109 77; 117 75],...
'VariableNames',labels_1,...
'RowNames',labels_2)
B = 3×4 table
FirstName Height Weight BloodPressure ___________ ______ ______ _____________ Garcia {'Michael'} 64 119 122 80 Johnson {'Beverly'} 69 163 109 77 Wu {'Alice' } 67 133 117 75
writetable(B,fullfile(path_save_table, 'B.csv'));
Unrecognized function or variable 'path_save_table'.
....the saved excel file does not show the first column on the left with the corresponding labels, i.e.:
labels_2 = {'Garcia' 'Johnson' 'Wu'}
Any suggestion in order to show the first column with the labels ?

Respuesta aceptada

Kevin Holly
Kevin Holly el 18 de Oct. de 2022
writetable(B,'B.csv','WriteRowNames',true);

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by