dlmread
Reads the values of a 2D matrix, R, from the file, f.
Syntax
R = dlmread(f)
R = dlmread(f, delim)
R = dlmread(f, ..., row, col)
R = dlmread(f, ..., dataRange)
R = dlmread(f, ..., 'emptyvalue', value)
R = dlmread(f, ..., 'ignoremultidelim', delimstate)
Inputs
- f
- File name or file handle opened by using fopen.
- delim
- Optional delimiter between values read. If no delimiter is specified, it will be determined from the file, f.
- row(optional)
- Specifies the row to read data from the file, f. row is zero-based.
- col(optional)
- Specifies the column to read data from the file, f. column is zero-based.
- dataRange(optional)
- Specifies the range of data read. The range could be specified as a 4-element vector in the form [r1, c1, r2, c2]. r1 and c1 are the start row/column the data is read from. r2 and c2 are the end row/column the data is read from. r1, c1, r2, and c2 are zero-based. Range can also be specified as a spreadsheet-style string such as 'A1..B5' or 'A1:B5', where A refers to column 1 of the data and 1 refers to the one-based start row of the data to be read.
- value(optional)
- Argument following the keyword 'emptyvalue', specifying the value to be used in the output, R, for empty or non-numeric values. By default, value is 0.
- delimstate(optional)
- Argument following the keyword 'ignoremultidelim', which is 'off' by default. If 'on' and there are multiple delimiters adjacent to each other in the file, they are treated as a single delimter.
Outputs
- R
- Matrix of values read from the file, f.
Examples
R = dlmread('Example1.txt');
R = [Matrix] 2 x 3
5.48813 6.45894 7.91725
0.87129 9.78618 6.39921
R = dlmread('Example2.txt', ' ', 2, 1)
R = [Matrix] 3 x 2
6.17636 3.59508
5.92845 -3.84382
6.48172 4.73608
R = dlmread('Example3.txt', [2, 1, 4, 2])
R = [Matrix] 3 x 2
6.17636 3.59508
5.92845 -3.84382
6.48172 4.73608
R = dlmread('Example4.txt', 'B1:D2')
R = [Matrix] 2 x 2
6.45894 7.91725
9.78618 6.39921
R = dlmread('Example4.txt', 'B1..D2')
R = [Matrix] 2 x 2
6.45894 7.91725
9.78618 6.39921
R = dlmread('Example5.txt', 'emptyvalue', -55)
R = [Matrix] 3 x 3
5.48813 -55.00000 -55.00000
0.87129 9.78618 6.39921
2.64556 6.17636 3.59508