writetable for a double entry table

16 vues (au cours des 30 derniers jours)
Sim
Sim le 18 Oct 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 ?

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by