2013年8月20日星期二

(转)把mat文件保存为txt格式而不损失精度

Subject:

How can I avoid truncation and loss of precision when saving my data in MATLAB?

Problem Description:

I have tried saving my data with SAVE -ASCII (or FPRINTF, DLMWRITE, etc.) and notice that I lose precision when I do this.

Solution:

To obtain 16-digit ASCII format using the SAVE function, use the following command:
save -ascii -double Following is an example of writing "pi" to a TXT-file with double precision using DLMWRITE:
dlmwrite('myfile1.txt', pi, 'delimiter', '\t', 'precision', 16)
For more information on precision specification, refer the respective documentation pages by executing the following MATLAB commands:
doc save
doc dlmwrite

Information on C-style format string allowed in DLMWRITE can be found here:
doc sprintf

参考:
 http://www.mathworks.cn/support/solutions/en/data/1-1CBW5/?product=SL&solution=1-1CBW5

没有评论:

发表评论