【转】matab中dlmread 和dlmwrite函数的具体应用

转自:http://www.ymlib.net/article/sort010/info-376.html

 

matab中dlmread 和dlmwrite函数的基本格式:
M = dlmread(filename, delimiter, R, C)
M = dlmread(filename, delimiter, range)
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'.
示例:



dlmwrite: Write matrix to ASCII-delimited file

1、定义输出格式:dlmwrite(filename, M, 'attrib1', value1, 'attrib2', value2, ...) is an alternate syntax to those shown above, in which you specify any number of attribute-value pairs in any order in the argument list.
属性定义:
delimiter(分割符): Delimiter string to be used in separating matrix elements.
newline(断行符):Character(s) to use in terminating each line.
(1) 'pc': PC terminator (implies carriage return/line feed (CR/LF))
(2) 'unix': UNIX terminator (implies line feed (LF))
roffset(行偏移): Offset, in rows, from the top of the destination file to where matrix data is to be written. Offset is zero based.
coffset(列偏移): Offset, in columns, from the left side of the destination file to where matrix data is to be written. Offset is zero based.
precision(输出精度): Specify the number of significant digits or a C-style format string starting in %, such as '%10.5f'.
示例:
dlmwrite('data.txt', data, 'precision', '%10.6f', 'roffset', 10, 'coffset', 10, 'delimiter', ';', 'newline', 'pc');


2、追加方式输出:dlmwrite(filename, M, '-append', attribute-value list) appends the matrix to the file. If you do not specify '-append', dlmwrite overwrites any existing data in the file. You can place the '-append' flag in the argument list anywhere between attribute-value pairs, but not in between an attribute and its value.
 

转载于:https://www.cnblogs.com/fzzl/archive/2011/09/14/2175343.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值