writetable for a double entry table

19 Ansichten (letzte 30 Tage)
Sim
Sim am 18 Okt. 2022
Beantwortet: Kevin Holly am 18 Okt. 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 ?

Akzeptierte Antwort

Kevin Holly
Kevin Holly am 18 Okt. 2022
writetable(B,'B.csv','WriteRowNames',true);

Weitere Antworten (0)

Kategorien

Mehr zu Tables 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