フィルターのクリア

writetable adds unnecessary columns to Excel file

5 ビュー (過去 30 日間)
Thomas Kirsh
Thomas Kirsh 2020 年 8 月 6 日
コメント済み: Thomas Kirsh 2020 年 8 月 7 日
I'm trying to save my table to an Excel spreadsheet.
test_limits = {'1', '2', '3'};
test_sens = {'0.54(0.02)', '0.89(0.01)', '0.34(0.01)'};
test_auc = {'0.78(0.04)', '0.91(0.02)', '0.64(0.02)'};
test_table = table(test_limits', test_sens', test_auc', 'VariableNames', {'Threshold', 'Sensitivity', 'AUC'});
writetable(test_table, 'test_table.xlsx')
However, when I open the file, the table is saved properly in the first 3 columns, but there are 6 more columns called "Sensitivity_1", "Sensitivity_2", "Sensitivity_3", "AUC_1", "AUC_2", "AUC_3" with the corresponding inputs in row format.
Why are these extra columns being added? I've tried transposing the variable name cell array but that doesn't change the results. I couldn't find any similar answers anywhere here.

採用された回答

Image Analyst
Image Analyst 2020 年 8 月 6 日
I see no such extra columns. Are you sure they're not still existing from a prior run where you forgot to transpose the variables while creating the table? It will just blast over cells, and any in there from a prior run will still be there. You might want to delete the workbook before you call writetable
fileName = 'test_table.xlsx';
if isfile(fileName)
delete(fileName);
end
writetable(test_table, fileName);
  1 件のコメント
Thomas Kirsh
Thomas Kirsh 2020 年 8 月 7 日
It seems that's what happened. After deleteing the files manually and running my code again, the extra columns don't appear. Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by