Main Content

dmwrite

Write DataMatrix object to text file

Syntax

dmwrite(DMObj, File)
dmwrite(..., 'Delimiter', DelimiterValue, ...)
dmwrite(..., 'Precision', PrecisionValue, ...)
dmwrite(..., 'Header', HeaderValue, ...)
dmwrite(..., 'Annotated', AnnotatedValue, ...)
dmwrite(..., 'Append', AppendValue, ...)

Arguments

DMObj

DataMatrix object, such as created by DataMatrix (object constructor).

File

Character vector specifying either a file name or a path and file name for saving the text file.

DelimiterValue

Character vector specifying a delimiter symbol to use as a matrix column separator. Typical choices are:

  • ' '

  • '\t' (default)

  • ','

  • ';'

  • '|'

PrecisionValue

Precision for writing the data to the text file, specified by either:

  • Positive integer specifying the number of significant digits

  • C-style format character vector starting with %, such as '%6.5f'

Default is 5.

HeaderValue

Character vector specifying the first line of the text file. Default is the Name property for the DataMatrix object.

AnnotatedValue

Controls the writing of row and column names to the text file. Choices are true (default) or false.

AppendValue

Controls the appending of DMObj to File when it is an existing file. Choices are true or false (default). If false, dmwrite overwrites File.

Description

dmwrite(DMObj, File) writes a DataMatrix object to a text file using the delimiter \t to separate DataMatrix columns. dmwrite writes the data starting at the first column of the first row in the destination file.

dmwrite(..., 'PropertyName', PropertyValue, ...) calls dmwrite with optional properties that use property name/property value pairs. You can specify one or more properties in any order. Enclose each PropertyName in single quotation marks. Each PropertyName is case insensitive. These property name/property value pairs are as follows:

dmwrite(..., 'Delimiter', DelimiterValue, ...) specifies a delimiter symbol to use as a column separator for separating matrix columns. Default is '\t'.

dmwrite(..., 'Precision', PrecisionValue, ...) specifies the precision for writing the data to the text file. Default is 5.

dmwrite(..., 'Header', HeaderValue, ...) specifies the first line of the text file. Default is the Name property for the DataMatrix object.

dmwrite(..., 'Annotated', AnnotatedValue, ...) controls the writing of row and column names to the text file. Choices are true (default) or false.

dmwrite(..., 'Append', AppendValue, ...) controls the appending of DMObj to File when it is an existing file. Choices are true or false (default). If false, dmwrite overwrites File.

Examples

Create a DataMatrix object and write the contents to a text file:

% Create a DataMatrix object 
dmobj = bioma.data.DataMatrix(rand(2,3), {'Row1', 'Row2'}, ...
                                         {'Col1', 'Col2', 'Col3'})
% Write the DataMatrix object to a text file
dmwrite(dmobj,'testdm.txt')

Version History

Introduced in R2009b

See Also