<< writecell | Spreadsheet | writetable >> |
writematrix(M) |
writematrix(M, filename) |
writematrix(..., Name, Value) |
an numeric or logical matrix.
a string: filename destination.
Name-Value Arguments
writematrix writes an numeric matrix to an CSV format file.
writematrix does not support sparse matrices.
writematrix outputs numeric data in the long G format.
Available Name-Value Arguments
Name-value pairs must follow all other arguments.
The order of name-value pairs doesn't matter
Delimiter and QuoteStrings options only apply to delimited text files.
FileType: Specifies the type of output file
Syntax: 'FileType','text'
Supports delimited text files (.txt, .dat, .csv)
WriteMode: Controls how data is written to the file
Syntax: 'WriteMode', mode
Options:
'overwrite' (default) - Creates new file or replaces existing content
'append' - Adds data to end of existing file
If the target file doesn't exist, a new file will be created regardless of mode.
Delimiter: Defines the character used to separate fields
Syntax: 'Delimiter', delimiter
Available Delimiters: Only applicable for delimited text files.
Specifier | Alternative | Description |
---|---|---|
','
|
'comma'
|
Comma (default) |
' '
|
'space'
|
Space character |
'\t'
|
'tab'
|
Tab character |
';'
|
'semi'
|
Semicolon |
'|'
|
'bar'
|
Vertical bar |
QuoteStrings: Controls text quoting behavior (Only applicable for delimited text files).
'QuoteStrings', option
with options
'minimal' (default) Quotes only text containing delimiters, line endings, or quotes.
'all' Quotes all text variables.
'none' Uses no quotes.
A = [Inf, -Inf, NaN, 3];
filename = [tempdir(), 'writematrix_example.csv'];
writematrix(A, filename);
R = fileread(filename)
readcell, csvwrite, dlmread, fileread.
Version | Description |
---|---|
1.10.0 | initial version |
Allan CORNET