Using xlswrite with cell array, how to keep column of numerals as strings?

1 回表示 (過去 30 日間)
Darren Woods
Darren Woods 2023 年 10 月 18 日
回答済み: Dyuman Joshi 2023 年 10 月 18 日
I have a cell array that has various columns, some columns contain numbers, some are strings. One of the string columns contains some entries that are all numerals. When this gets saved using xlswrite, the numeral strings become numbers. One negative side effect is that any numeral string that starts with a '0' will drop this. Example:
my_cell_array = {'field1', 'field2', 'field3'; 12345, 'abcdef', '1a2b3c'; 54321, 'fedcba', '01234'}
Here the string '01234' will get saved in Excel as the number 1234 which I don't want as this entire column should remain as strings.
How can I get around this problem?
Thanks, Darren.

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 10 月 18 日
As you are working with R2023b, use writecell.
Note that the use of xlswrite is not recommended.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by