Data types in TABLE

1 回表示 (過去 30 日間)
Jean-Marie Sainthillier
Jean-Marie Sainthillier 2024 年 3 月 8 日
I create a TABLE with different data types.
For example :
sz = [1 6];
vartypes = ["string" "categorical" "categorical" "categorical" "double" "double"];
noms = ["Screening" "Rando" "Side" "Treatment" "CS_T0" "CS_T1"];
data = table('Size', sz , 'VariableTypes' , vartypes, 'VariableNames', noms);
% ...
% Some processing
% ...
writetable(data, 'Résultats.xlsx');
If I understand correctly, I lose necessarily data types when I use writetable. Everything becomes either double or cellstr.
I know that I can overcome this limitation with detectImportOptions or Import Tool but you confirm that there is no way to find types automatically (just with information stored in the xlsx file) ?
A last question with no direct connection, why data types are not stored by default in the properties of the table ?
I find unnatural to get out of the class with varfun(@class,data) to obtain this information.
Thank in advance.
SAINTHILLIER Jean Marie

採用された回答

Walter Roberson
Walter Roberson 2024 年 3 月 8 日
Excel itself recognizes:
  • numbers (including dates)
  • text
  • logical
  • error such as #VALUE!
Excel is unable to distinguish between character and string, and has no concept of categorical.
  1 件のコメント
Jean-Marie Sainthillier
Jean-Marie Sainthillier 2024 年 3 月 11 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by