幼儿裤子裁剪视频教程:matlab函数dlmread:读取有分隔符的ASCII文件到矩阵函数 - Matlab编...

来源:百度文库 编辑:偶看新闻 时间:2024/05/01 23:38:14
matlab函数dlmread:读取有分隔符的ASCII文件到矩阵函数matlab, dlmread, 读取文本文件为矩阵 dlmread

读取有分隔符的ASCII文件到矩阵函数

图形接口

作为dlmread的替代,可以使用导入向导。可以从【File菜单】中激活导入向导。

语法

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

描述

M = dlmread('filename') 从由filename指定的具有分割标志的ASCII文件中读取数值数据,使用一个分隔符作为格式化的文件的暗示信息。默认分隔符使用逗号(,)。

M = dlmread('filename', delimiter) 这里指定了分隔符。使用\t代表制表符tab分隔。

注意:当从格式文件推断分隔符时,连续的空格符作为一个分隔符对待。但是不同的是, 如果通过分隔符输入参数指定了分隔符,那么重复的分隔字符将分别作为单独的分隔符对待。

M = dlmread('filename', delimiter, R, C)  R和C指定了数据在文件中的左上角位置。R和C的值从0开始。R = 0, C = 0指定了了文件中的第一个值,位于文件的左上角。

M = dlmread('filename', delimiter, range) 读取由range定义的区域块的数值,range = [R1 C1 R2 C2] 。也可以使用电子表格符号来指定,range = 'A1..B7'.。

备注

dlmread将用0填充没有边界的区域。有多行的数据文件,如果以非空格分隔符结束,例如分号,则在导入后将会多产生一行全0的列与最后。

dlmread在导入任何复数时,将作为一个整体导入一个复数单元中,转换实部和虚部到特定的数据类型。正确的复数格式为
  ±±i|j   5.7-3.1i
  ±i|j   -7j
嵌入了空格的复数是不正确的格式,空格将被认为是分隔符。

其他类似函数

dlmwrite, textscan, csvread, csvwrite, wk1read, wk1write

【jink2005译】



---------------------------------------------------
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')
M = dlmread('filename', delimiter)
M = dlmread('filename', delimiter, R, C)
M = dlmread('filename', delimiter, range)

Description

M = dlmread('filename') reads numeric data from the ASCII-delimited file filename, using a delimiter inferred from the formatting of the file. Comma (,) is the default delimiter.

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

Note    When a delimiter is inferred from the formatting of the file, consecutive whitespaces are treated as a single delimiter. By contrast, if a delimiter is specified by the delimiter input, any repeated delimiter character is treated as a separate 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. You can also specify the range using spreadsheet notation, as in range = 'A1..B7'.

Remarks

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

dlmread imports any complex number as a whole into a complex numeric field, converting the real and imaginary parts to the specified numeric type. Valid forms for a complex number are
  ±±i|j   5.7-3.1i
  ±i|j   -7j
Embedded white-space in a complex number is invalid and is regarded as a field delimiter.

See Also

dlmwrite, textscan, csvread, csvwrite, wk1read, wk1write