Writetable logical table to excel as zeros and ones

5 ビュー (過去 30 日間)
Erwin Werkhoven
Erwin Werkhoven 2023 年 1 月 30 日
回答済み: Erwin Werkhoven 2023 年 2 月 6 日
Hi,
I have a large table containing only logicals. If I use writetable to write the table to a csv file, it writes ones and zeros. That's what I want.
% masks.accepted a table with only logicals
filterdump_file = fullfile(capmat_out_folder, "filterdump.csv");
writetable(masks.accepted, filterdump_file);
But if have write the exact same table to an excel file, it writes "true" and "false".
% masks.accepted a table with only logicals
capmat_out_file = fullfile(capmat_out_folder, strcat(capmat_file_basename, "_out.xlsx"));
writetable(masks.accepted, capmat_out_file, "Sheet", "Filter Dump", "AutoFitWidth",false);
Why does writetable write ones and zeros to a csv file, and "true" and "false" to an excel file? Besides that, writing to a csv file is done in a few seconds, but writing to an excel file takes like 10+ mins. How can I get matlab/writetable to write ones and zeros to an excel file?
Thanks in advance

採用された回答

Erwin Werkhoven
Erwin Werkhoven 2023 年 2 月 6 日
print_accepted = convertvars(masks.accepted, @islogical, 'uint8');

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 1 月 30 日
Write out double() of the logical array.
  2 件のコメント
Erwin Werkhoven
Erwin Werkhoven 2023 年 2 月 6 日
I don't think that works, since mask.accepted is not a logical array but a table.
Erwin Werkhoven
Erwin Werkhoven 2023 年 2 月 6 日
Looks like this does the job:
print_accepted = convertvars(masks.accepted, @islogical, 'uint8');

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

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by