Friday, July 31, 2009

dlmread

Read an ASCII delimited file into a matrix

Graphical Interface

As an alternative to dlmread, use the Import Wizard. To activate the Import Wizard, select Import data from the File menu.

Syntax

  • M = dlmread(filename,delimiter)
    M = dlmread(filename,delimiter,R,C)
    M = dlmread(filename,delimiter,range)

Description

M = dlmread(filename,delimiter) reads numeric data from the ASCII delimited file filename, using the specified delimiter. A comma (,) is the default delimiter. Use '\t' to specify a tab delimiter.

M = dlmread(filename,delimiter,R,C) reads numeric data from the ASCII delimited file filename, using the specified delimiter. The values R and C specify the row and column where the upper-left corner of the data lies in the file. R and C are zero based so that R=0, C=0 specifies the first value in the file, which is the upper left corner.

M = dlmread(filename,delimiter,range) reads the range specified by
range = [R1 C1 R2 C2] where (R1,C1) is the upper-left corner of the data to be read and (R2,C2) is the lower-right corner. range can also be specified using spreadsheet notation as in range = 'A1..B7'.

Remarks

dlmread fills empty delimited fields with zero. Data files having lines that end with a non-space delimiter, such as a semi-colon, produce a result that has an additional last column of zeros.



dlmwrite

Write a matrix to an ASCII delimited file

Syntax

  • dlmwrite(filename,M,delimiter)
    dlmwrite(filename,M,delimiter,R,C)

Description

dlmwrite(filename,M,delimiter) writes matrix M into an ASCII-format file, using delimiter to separate matrix elements. The data is written to the upper left-most cell of the spreadsheet filename. A comma (,) is the default delimiter. Use '\t' to produce tab-delimited files.

dlmwrite(filename,M,delimiter,R,C) writes matrix A into an ASCII-format file, using delimiter to separate matrix elements. The data is written to the spreadsheet filename, starting at spreadsheet cell R and C, where R is the row offset and C is the column offset. R and C are zero based so that R=0, C=0 specifies the first value in the file, which is the upper left corner.

Remarks

The resulting file is readable by spreadsheet programs.

No comments:

Post a Comment