How do I get the raw 'xlsread' cell array format when transitioning to readtable/​readcell/r​eadmatrix?

10 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 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:
  • 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. 

Plus de réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by