Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2012-04-05, 15:03   #1
babybear
初级会员
 
注册日期: 2012-04-05
帖子: 1
声望力: 0
babybear 正向着好的方向发展
不错 关于将matlab中的数据存成text格式文件

在matlab中的有一64*61的矩阵,我想按顺序将它存到一个.text格式的文件中,我使用的命令语句是dlmwrite('singal.txt', signal, 'delimiter', '\t','precision', 16)
可是生成的text中不是64*61的,请各位帮下忙~麻烦啦

此帖于 2012-04-05 15:23 被 babybear 编辑。
babybear 当前离线   回复时引用此帖
旧 2012-04-05, 19:19   #2
yhcode
高级会员
 
注册日期: 2008-05-13
年龄: 44
帖子: 232
声望力: 21
yhcode 正向着好的方向发展
默认 回复: 关于将matlab中的数据存成text格式文件

你的指令应该没有问题呀,是不是16位精度太高了。
下面是MALTAB HELP中dlmwrite指令的Example,你的方法就是第一个example:
Examples
Example 1

Export matrix M to a file delimited by the tab character and using a precision of six significant digits:

dlmwrite('myfile.txt', M, 'delimiter', '\t', ...
'precision', 6)
type myfile.txt

0.893898 0.284409 0.582792 0.432907
0.199138 0.469224 0.423496 0.22595
0.298723 0.0647811 0.515512 0.579807
0.661443 0.988335 0.333951 0.760365

Example 2

Export matrix M to a file using a precision of six decimal places and the conventional line terminator for the PC platform:

dlmwrite('myfile.txt', m, 'precision', '%.6f', ...
'newline', 'pc')
type myfile.txt

16.000000,2.000000,3.000000,13.000000
5.000000,11.000000,10.000000,8.000000
9.000000,7.000000,6.000000,12.000000
4.000000,14.000000,15.000000,1.000000

Example 3

Export matrix M to a file, and then append an additional matrix to the file that is offset one row below the first:

M = magic(3);
dlmwrite('myfile.txt', [M*5 M/5], ' ')

dlmwrite('myfile.txt', rand(3), '-append', ...
'roffset', 1, 'delimiter', ' ')

type myfile.txt

40 5 30 1.6 0.2 1.2
15 25 35 0.6 1 1.4
20 45 10 0.8 1.8 0.4

0.81472 0.91338 0.2785
0.90579 0.63236 0.54688
0.12699 0.09754 0.95751

When dlmread imports these two matrices from the file, it pads the smaller matrix with zeros:

dlmread('myfile.txt')
40.0000 5.0000 30.0000 1.6000 0.2000 1.2000
15.0000 25.0000 35.0000 0.6000 1.0000 1.4000
20.0000 45.0000 10.0000 0.8000 1.8000 0.4000
0.8147 0.9134 0.2785 0 0 0
0.9058 0.6324 0.5469 0 0 0
0.1270 0.0975 0.9575 0 0 0
__________________
工科'985'博士,(图像处理、分析及理解;模式识别;运动估计;数据分析等)定做程序、算法实现--qq:752105755
yhcode 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 09:09


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.