FUNCTION REFERENCE

writecell

Write a cell array to a delimited text file.

Write a cell array to a delimited text file.

Syntax

writecell(C, 'out.csv')

Syntax

writecell(C, 'out.txt', 'Delimiter', 'tab')

Syntax

writecell(C, 'out.csv', 'QuoteStrings', true)

Each cell must hold a numeric or logical scalar, text (character vector or string scalar) or an empty value. Numbers are written in the shortest form that reads back exactly (logical as 1 or 0, NaN and Inf by name); text that contains the delimiter, a quote or a line break is put in double quotes with inner quotes doubled, and 'QuoteStrings', true quotes all text. Delimiter is comma (default), semicolon, tab, bar or space, given as the character or its name. Use a .csv, .txt or .dat name, or add 'FileType', 'text'; a name without an extension gets .txt. Call it as a statement.

Example

writecell({'a',1;'b',2},'pairs.csv')   % writes a,1 and b,2

Differences from MATLAB: Overwrites the file only (no append). Writing spreadsheets (.xlsx, .xls) is not supported yet and gives an error. Cells holding arrays, cells, structs or datetimes are rejected.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.