- The function 'readmatrix' should be used if all the data is of the same type.
- The 'readtable' function makes use of the "Table" data type, which we recommend for cases where there are multiple rows of data where each has multiple heterogeneous fields, but each of those fields has a consistent datatype.
How do I get the raw 'xlsread' cell array format when transitioning to readtable/readcell/readmatrix?
8 views (last 30 days)
Show older comments
MathWorks Support Team
on 23 Nov 2021
Commented: Julian Hapke
on 22 Aug 2022
I am trying to replace all 'xlsread' functions in my code with the new readtable/readcell/readmatrix functions. I would like the resulting output to be in the same format as when I was using 'xlsread'.
The 'xlsread' function had the following syntax:
[num,txt,raw] = xlsread(___)
How do I get output equivalent to the raw output of 'xlsread', meaning that it needs to be in cell array format, not double. 'readtable' or 'readmatrix' save as double and put NaN whenever there are non-numeric data.
Accepted Answer
MathWorks Support Team
on 23 Nov 2021
When switching from 'xlsread', there are now three functions that can be used to import from Excel sheets as well as other file formats: 'readcell', 'readmatrix' and 'readtable'.
The 'readcell' option produces an output closest to the 'raw' output parameter of 'xlsread'. 'readcell' should be used for the case where the data in the file is completely mixed. It will bring data in as text if it cannot otherwise be converted to a number, datetime, or duration.
In addition, the other replacement functions should be used in the following situations:
1 Comment
Julian Hapke
on 22 Aug 2022
I think there should be an option to force readcell to read everything as char / string.
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!