FUNCTION REFERENCE
readcell
Read a text or spreadsheet file into a cell array.
Read a text or spreadsheet file into a cell array.
Syntax
C = readcell('data.csv')Syntax
C = readcell('data.txt', 'Delimiter', ';', 'NumHeaderLines', 1)Syntax
C = readcell('data.csv', 'Range', 'B2:C5')Syntax
C = readcell('book.xlsx', 'Sheet', 2, 'Range', 'A1:D10')Syntax
C = readcell(filename, opts)With import options from detectImportOptions, the selected variables are converted to their types (numbers, text, datetime, duration, categorical, logical) and each value fills one cell; empty and unconvertible fields take the variable's FillValue unless MissingRule or ImportErrorRule omit them.
Returns one cell per field. Fields that read as numbers (including Inf and NaN) become doubles, other text becomes character vectors with surrounding spaces removed, and empty fields become missing. Quoted fields stay text and may contain the delimiter, line breaks and doubled quotes. Without Delimiter, the most frequent of comma, tab, semicolon and bar outside quotes in the first lines is used. If none occurs, space is used. Set Delimiter to ' ', 'space', 'whitespace' or a list such as {' ', '\t'} to join runs of spaces and tabs and ignore leading and trailing whitespace. Blank lines are skipped and short rows are padded with missing. NumHeaderLines skips leading lines; Range ('A1:C10' or a start cell 'B2') counts lines and fields of the file, and blank lines inside it become rows of missing. For .xlsx, .xlsm, .xlsb and .xls files (or 'FileType', 'spreadsheet') numbers become doubles, logical cells logical, text character vectors and empty cells missing; Sheet picks a sheet by name or 1-based index, and NumHeaderLines counts sheet rows from row 1.
Example
writecell({'name','size';'bolt',4},'parts.csv'); C = readcell('parts.csv') % 2-by-2 cell: {'name','size';'bolt',4}Differences from MATLAB: Missing entries hold a missing string (class string), not a missing object. Dates, durations and complex numbers in text files stay text; spreadsheet dates read as Excel serial numbers. NumHeaderLines and Range cannot be combined. Results are limited to 65536 cells; text files to 64 MiB. An .xls workbook is read whole and is limited to 16777216 cells over all its sheets.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.