Write cell array to file
writecell(
writes cell array
C
)C
to a comma delimited text file. The file name is the workspace name
of the cell array, appended with the extension .txt
. If
writecell
cannot construct the file name from the input cell array
name, then it writes to the file cell.txt
.
Each column of each variable in C
becomes a column in the output
file. The writecell
function overwrites any existing file.
writecell(
writes to a file with the name and extension specified by
C
,filename
)filename
.
writecell
determines the file format based on the specified
extension. The extension must be one of the following:
.txt
, .dat
, or .csv
for
delimited text files
.xls
, .xlsm
, or .xlsx
for
Excel® spreadsheet files
.xlsb
for Excel spreadsheet files supported on systems with Excel for Windows®
writecell(___,
writes
the cell array to a file with additional options specified by one or more
Name,Value
)Name,Value
pair arguments and can include any of the input arguments
in previous syntaxes.
To set the 'PreserveFormat'
name-value pair to
true
, you must set the 'UseExcel'
name-value pair
to true
.
There are some instances where the writecell
function creates a file
that does not represent the input data exactly. You will notice this when you use the
readcell
function
to read that file. The resulting data might not have the exact same format or contents as the
original data. If you need to save your cell array and retrieve it at a later time to exactly
match the original cell array, with the same data and organization, then save it as a
MAT-file. writecell
writes an inexact table in the following instances:
writecell
writes out numeric data using long
g
format, and categorical or character data as unquoted text.
writecell
writes out cell arrays that have more than two
dimensions as two dimensional arrays, with the trailing dimensions collapsed.